добавление поля описания к настрокам среды

правки по доступу к данным
This commit is contained in:
kotcheshir73 2021-03-28 20:56:32 +04:00
parent c5001cbd7a
commit fa5b3abe82
9 changed files with 269 additions and 13 deletions

View File

@ -0,0 +1,220 @@
// <auto-generated />
using System;
using DatabaseCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace DatabaseCore.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20210328165041_AddDescriptionInEnviromentSettings")]
partial class AddDescriptionInEnviromentSettings
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("ProductVersion", "5.0.4")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("DatabaseCore.Models.Security.Access", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<int>("AccessOperation")
.HasColumnType("int");
b.Property<int>("AccessType")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<Guid>("RoleId")
.HasColumnType("uniqueidentifier");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("Accesses");
});
modelBuilder.Entity("DatabaseCore.Models.Security.EnviromentSetting", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<string>("Key")
.HasColumnType("nvarchar(max)");
b.Property<string>("Value")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("EnviromentSettings");
});
modelBuilder.Entity("DatabaseCore.Models.Security.Role", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("RoleName")
.HasColumnType("nvarchar(max)");
b.Property<int>("RolePriority")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Roles");
});
modelBuilder.Entity("DatabaseCore.Models.Security.User", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<byte[]>("Avatar")
.HasColumnType("varbinary(max)");
b.Property<int>("CountAttempt")
.HasColumnType("int");
b.Property<DateTime?>("DateBanned")
.HasColumnType("datetime2");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateLastVisit")
.HasColumnType("datetime2");
b.Property<Guid?>("EmployeeId")
.HasColumnType("uniqueidentifier");
b.Property<bool>("IsBanned")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<Guid?>("LecturerId")
.HasColumnType("uniqueidentifier");
b.Property<string>("PasswordHash")
.HasColumnType("nvarchar(max)");
b.Property<Guid?>("StudentId")
.HasColumnType("uniqueidentifier");
b.Property<string>("UserName")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("DatabaseCore.Models.Security.UserRole", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<Guid>("RoleId")
.HasColumnType("uniqueidentifier");
b.Property<Guid>("UserId")
.HasColumnType("uniqueidentifier");
b.HasKey("Id");
b.HasIndex("RoleId");
b.HasIndex("UserId");
b.ToTable("UserRoles");
});
modelBuilder.Entity("DatabaseCore.Models.Security.Access", b =>
{
b.HasOne("DatabaseCore.Models.Security.Role", "Role")
.WithMany("Access")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
});
modelBuilder.Entity("DatabaseCore.Models.Security.UserRole", b =>
{
b.HasOne("DatabaseCore.Models.Security.Role", "Role")
.WithMany("UserRoles")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseCore.Models.Security.User", "User")
.WithMany("UserRoles")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
b.Navigation("User");
});
modelBuilder.Entity("DatabaseCore.Models.Security.Role", b =>
{
b.Navigation("Access");
b.Navigation("UserRoles");
});
modelBuilder.Entity("DatabaseCore.Models.Security.User", b =>
{
b.Navigation("UserRoles");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,23 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace DatabaseCore.Migrations
{
public partial class AddDescriptionInEnviromentSettings : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Description",
table: "EnviromentSettings",
type: "nvarchar(max)",
nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Description",
table: "EnviromentSettings");
}
}
}

View File

@ -54,6 +54,9 @@ namespace DatabaseCore.Migrations
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<string>("Key")
.HasColumnType("nvarchar(max)");

View File

@ -17,5 +17,9 @@ namespace DatabaseCore.Models.Security
[DataMember]
[MapConfiguration("Value")]
public string Value { get; set; }
[DataMember]
[MapConfiguration("Description")]
public string Description { get; set; }
}
}

View File

@ -70,11 +70,10 @@ namespace ModuleTools.BusinessLogics
{
if (Security.CheckAccess(new SecurityManagerCheckAccessModel(model, _serviceOperation, type, _entity)))
{
return false;
Errors.Add(("Ошибка безопасности", Security.ErrorMessage));
return true;
}
Errors.Add(("Ошибка безопасности", Security.ErrorMessage));
return true;
return false;
}
/// <summary>

View File

@ -21,5 +21,8 @@ namespace SecurityBusinessLogic.BindingModels
[Required(ErrorMessage = "required")]
public string Value { get; set; }
[Required(ErrorMessage = "required")]
public string Description { get; set; }
}
}

View File

@ -15,20 +15,20 @@ namespace SecurityBusinessLogic.ViewModels
/// </summary>
public class AccessViewModel : ElementViewModel
{
[MapConfiguration("RoleId")]
[MapConfiguration("RoleId", AllowCopyWithoutRigth = false)]
public Guid RoleId { get; set; }
[ViewModelOnListProperty("Роль", 100)]
[MapConfiguration("Role.RoleName", true)]
[MapConfiguration("Role.RoleName", true, AllowCopyWithoutRigth = false)]
public string RoleName { get; set; }
[MapConfiguration("AccessOperation")]
[MapConfiguration("AccessOperation", AllowCopyWithoutRigth = false)]
public AccessOperation AccessOperation { get; set; }
[ViewModelOnListProperty("Операция")]
public string AccessOperationTitle => AccessOperation.ToString("G");
[MapConfiguration("AccessType")]
[MapConfiguration("AccessType", AllowCopyWithoutRigth = false)]
public AccessType AccessType { get; set; }
[ViewModelOnListProperty("Тип", 150)]

View File

@ -14,13 +14,17 @@ namespace SecurityBusinessLogic.ViewModels
public class EnviromentSettingViewModel : ElementViewModel
{
[ViewModelOnListProperty("Ключ")]
[MapConfiguration("Key")]
[MapConfiguration("Key", AllowCopyWithoutRigth = false)]
public string Key { get; set; }
[ViewModelOnListProperty("Значение")]
[MapConfiguration("Value")]
[MapConfiguration("Value", AllowCopyWithoutRigth = false)]
public string Value { get; set; }
[ViewModelOnListProperty("Описание")]
[MapConfiguration("Description", AllowCopyWithoutRigth = false)]
public string Description { get; set; }
public override string ToString() => Key;
}
}

View File

@ -34,19 +34,19 @@ namespace SecurityBusinessLogic.ViewModels
[MapConfiguration("DateLastVisit")]
public DateTime? DateLastVisit { get; set; }
[MapConfiguration("IsBanned")]
[MapConfiguration("IsBanned", AllowCopyWithoutRigth = false)]
public bool IsBanned { get; set; }
[ViewModelOnListProperty("Блокир.", 80)]
public string Banned => IsBanned ? "Да" : "Нет";
[MapConfiguration("DateBanned")]
[MapConfiguration("DateBanned", AllowCopyWithoutRigth = false)]
public DateTime? DateBanned { get; set; }
[ViewModelOnListProperty("Дата Б.", 100)]
public string DateBannedTitle => DateBanned.HasValue ? DateBanned.Value.ToShortDateString() : string.Empty;
[MapConfiguration("CountAttempt")]
[MapConfiguration("CountAttempt", AllowCopyWithoutRigth = false)]
public int CountAttempt { get; set; }
public override string ToString() => Login;