Дисципилны

This commit is contained in:
kotcheshir73 2021-04-03 19:03:56 +04:00
parent ecee1a9eeb
commit 985c119bb9
44 changed files with 2228 additions and 23 deletions

View File

@ -37,6 +37,10 @@ namespace DatabaseCore
modelBuilder.Entity<Employee>().HasIndex(p => new { p.FirstName, p.LastName, p.Patronymic }).IsUnique();
modelBuilder.Entity<Classroom>().HasIndex(p => new { p.Number }).IsUnique();
modelBuilder.Entity<DisciplineBlock>().HasIndex(p => new { p.Title }).IsUnique();
modelBuilder.Entity<Discipline>().HasIndex(p => new { p.DisciplineName }).IsUnique();
}
#region Security
@ -52,6 +56,8 @@ namespace DatabaseCore
public virtual DbSet<Employee> Employees { set; get; }
public virtual DbSet<EmployeeEmployeePost> EmployeeEmployeePosts { set; get; }
public virtual DbSet<Classroom> Classrooms { set; get; }
public virtual DbSet<DisciplineBlock> DisciplineBlocks { set; get; }
public virtual DbSet<Discipline> Disciplines { set; get; }
#endregion
}
}

View File

@ -0,0 +1,535 @@
// <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("20210403143118_AddDisciplines")]
partial class AddDisciplines
{
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.Department.Classroom", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<int>("Capacity")
.HasColumnType("int");
b.Property<int>("ClassroomType")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<Guid>("EmployeeId")
.HasColumnType("uniqueidentifier");
b.Property<bool>("HaveProjector")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("Number")
.HasColumnType("nvarchar(450)");
b.Property<byte[]>("Photo")
.HasColumnType("varbinary(max)");
b.Property<string>("SecurityCode")
.HasColumnType("nvarchar(max)");
b.Property<decimal>("Square")
.HasColumnType("decimal(18,2)");
b.Property<string>("Title")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("EmployeeId");
b.HasIndex("Number")
.IsUnique()
.HasFilter("[Number] IS NOT NULL");
b.ToTable("Classrooms");
});
modelBuilder.Entity("DatabaseCore.Models.Department.Discipline", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<Guid>("DisciplineBlockId")
.HasColumnType("uniqueidentifier");
b.Property<string>("DisciplineBlueAsteriskName")
.HasColumnType("nvarchar(max)");
b.Property<string>("DisciplineName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("DisciplineShortName")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.HasKey("Id");
b.HasIndex("DisciplineBlockId");
b.HasIndex("DisciplineName")
.IsUnique();
b.ToTable("Disciplines");
});
modelBuilder.Entity("DatabaseCore.Models.Department.DisciplineBlock", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<string>("DisciplineBlockBlueAsteriskName")
.HasColumnType("nvarchar(max)");
b.Property<int>("DisciplineBlockOrder")
.HasColumnType("int");
b.Property<bool>("DisciplineBlockUseForGrouping")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
b.HasIndex("Title")
.IsUnique();
b.ToTable("DisciplineBlocks");
});
modelBuilder.Entity("DatabaseCore.Models.Department.Employee", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<string>("Address")
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("DateBirth")
.HasColumnType("datetime2");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.HasColumnType("nvarchar(max)");
b.Property<string>("FirstName")
.HasColumnType("nvarchar(450)");
b.Property<string>("GroupElectricalSafety")
.HasColumnType("nvarchar(max)");
b.Property<string>("HomeNumber")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("LastName")
.HasColumnType("nvarchar(450)");
b.Property<string>("MobileNumber")
.HasColumnType("nvarchar(max)");
b.Property<string>("Patronymic")
.HasColumnType("nvarchar(450)");
b.Property<byte[]>("Photo")
.HasColumnType("varbinary(max)");
b.Property<Guid>("UserId")
.HasColumnType("uniqueidentifier");
b.HasKey("Id");
b.HasIndex("FirstName", "LastName", "Patronymic")
.IsUnique()
.HasFilter("[FirstName] IS NOT NULL AND [LastName] IS NOT NULL AND [Patronymic] IS NOT NULL");
b.ToTable("Employees");
});
modelBuilder.Entity("DatabaseCore.Models.Department.EmployeeEmployeePost", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<Guid>("EmployeeId")
.HasColumnType("uniqueidentifier");
b.Property<Guid>("EmployeePostId")
.HasColumnType("uniqueidentifier");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<bool>("IsExternalCombination")
.HasColumnType("bit");
b.Property<bool>("IsInternalCombination")
.HasColumnType("bit");
b.Property<decimal>("Rate")
.HasColumnType("decimal(18,2)");
b.HasKey("Id");
b.HasIndex("EmployeeId");
b.HasIndex("EmployeePostId");
b.ToTable("EmployeeEmployeePosts");
});
modelBuilder.Entity("DatabaseCore.Models.Department.EmployeePost", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<string>("EmployeePostName")
.HasColumnType("nvarchar(450)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<int>("Order")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("EmployeePostName")
.IsUnique()
.HasFilter("[EmployeePostName] IS NOT NULL");
b.ToTable("EmployeePosts");
});
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")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("Value")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("Key")
.IsUnique();
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")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int>("RolePriority")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("RoleName")
.IsUnique();
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<bool>("IsBanned")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("PasswordHash")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("UserName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
b.HasIndex("UserName");
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.Department.Classroom", b =>
{
b.HasOne("DatabaseCore.Models.Department.Employee", "Employee")
.WithMany("Classrooms")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
});
modelBuilder.Entity("DatabaseCore.Models.Department.Discipline", b =>
{
b.HasOne("DatabaseCore.Models.Department.DisciplineBlock", "DisciplineBlock")
.WithMany("Disciplines")
.HasForeignKey("DisciplineBlockId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("DisciplineBlock");
});
modelBuilder.Entity("DatabaseCore.Models.Department.EmployeeEmployeePost", b =>
{
b.HasOne("DatabaseCore.Models.Department.Employee", "Employee")
.WithMany("EmployeeEmployeePosts")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseCore.Models.Department.EmployeePost", "EmployeePost")
.WithMany("EmployeeEmployeePosts")
.HasForeignKey("EmployeePostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
b.Navigation("EmployeePost");
});
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.Department.DisciplineBlock", b =>
{
b.Navigation("Disciplines");
});
modelBuilder.Entity("DatabaseCore.Models.Department.Employee", b =>
{
b.Navigation("Classrooms");
b.Navigation("EmployeeEmployeePosts");
});
modelBuilder.Entity("DatabaseCore.Models.Department.EmployeePost", b =>
{
b.Navigation("EmployeeEmployeePosts");
});
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,154 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace DatabaseCore.Migrations
{
public partial class AddDisciplines : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Roles_RoleName",
table: "Roles");
migrationBuilder.AlterColumn<string>(
name: "UserName",
table: "Users",
type: "nvarchar(450)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(450)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "PasswordHash",
table: "Users",
type: "nvarchar(max)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "RoleName",
table: "Roles",
type: "nvarchar(450)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(450)",
oldNullable: true);
migrationBuilder.CreateTable(
name: "DisciplineBlocks",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Title = table.Column<string>(type: "nvarchar(450)", nullable: false),
DisciplineBlockUseForGrouping = table.Column<bool>(type: "bit", nullable: false),
DisciplineBlockOrder = table.Column<int>(type: "int", nullable: false),
DisciplineBlockBlueAsteriskName = table.Column<string>(type: "nvarchar(max)", nullable: true),
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
DateDelete = table.Column<DateTime>(type: "datetime2", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DisciplineBlocks", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Disciplines",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
DisciplineBlockId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
DisciplineName = table.Column<string>(type: "nvarchar(450)", nullable: false),
DisciplineShortName = table.Column<string>(type: "nvarchar(max)", nullable: true),
DisciplineBlueAsteriskName = table.Column<string>(type: "nvarchar(max)", nullable: true),
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
DateDelete = table.Column<DateTime>(type: "datetime2", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Disciplines", x => x.Id);
table.ForeignKey(
name: "FK_Disciplines_DisciplineBlocks_DisciplineBlockId",
column: x => x.DisciplineBlockId,
principalTable: "DisciplineBlocks",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Roles_RoleName",
table: "Roles",
column: "RoleName",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_DisciplineBlocks_Title",
table: "DisciplineBlocks",
column: "Title",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Disciplines_DisciplineBlockId",
table: "Disciplines",
column: "DisciplineBlockId");
migrationBuilder.CreateIndex(
name: "IX_Disciplines_DisciplineName",
table: "Disciplines",
column: "DisciplineName",
unique: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Disciplines");
migrationBuilder.DropTable(
name: "DisciplineBlocks");
migrationBuilder.DropIndex(
name: "IX_Roles_RoleName",
table: "Roles");
migrationBuilder.AlterColumn<string>(
name: "UserName",
table: "Users",
type: "nvarchar(450)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(450)");
migrationBuilder.AlterColumn<string>(
name: "PasswordHash",
table: "Users",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)");
migrationBuilder.AlterColumn<string>(
name: "RoleName",
table: "Roles",
type: "nvarchar(450)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(450)");
migrationBuilder.CreateIndex(
name: "IX_Roles_RoleName",
table: "Roles",
column: "RoleName",
unique: true,
filter: "[RoleName] IS NOT NULL");
}
}
}

View File

@ -74,6 +74,78 @@ namespace DatabaseCore.Migrations
b.ToTable("Classrooms");
});
modelBuilder.Entity("DatabaseCore.Models.Department.Discipline", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<Guid>("DisciplineBlockId")
.HasColumnType("uniqueidentifier");
b.Property<string>("DisciplineBlueAsteriskName")
.HasColumnType("nvarchar(max)");
b.Property<string>("DisciplineName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("DisciplineShortName")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.HasKey("Id");
b.HasIndex("DisciplineBlockId");
b.HasIndex("DisciplineName")
.IsUnique();
b.ToTable("Disciplines");
});
modelBuilder.Entity("DatabaseCore.Models.Department.DisciplineBlock", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateDelete")
.HasColumnType("datetime2");
b.Property<string>("DisciplineBlockBlueAsteriskName")
.HasColumnType("nvarchar(max)");
b.Property<int>("DisciplineBlockOrder")
.HasColumnType("int");
b.Property<bool>("DisciplineBlockUseForGrouping")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
b.HasIndex("Title")
.IsUnique();
b.ToTable("DisciplineBlocks");
});
modelBuilder.Entity("DatabaseCore.Models.Department.Employee", b =>
{
b.Property<Guid>("Id")
@ -269,6 +341,7 @@ namespace DatabaseCore.Migrations
.HasColumnType("bit");
b.Property<string>("RoleName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int>("RolePriority")
@ -277,8 +350,7 @@ namespace DatabaseCore.Migrations
b.HasKey("Id");
b.HasIndex("RoleName")
.IsUnique()
.HasFilter("[RoleName] IS NOT NULL");
.IsUnique();
b.ToTable("Roles");
});
@ -313,9 +385,11 @@ namespace DatabaseCore.Migrations
.HasColumnType("bit");
b.Property<string>("PasswordHash")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("UserName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
@ -365,6 +439,17 @@ namespace DatabaseCore.Migrations
b.Navigation("Employee");
});
modelBuilder.Entity("DatabaseCore.Models.Department.Discipline", b =>
{
b.HasOne("DatabaseCore.Models.Department.DisciplineBlock", "DisciplineBlock")
.WithMany("Disciplines")
.HasForeignKey("DisciplineBlockId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("DisciplineBlock");
});
modelBuilder.Entity("DatabaseCore.Models.Department.EmployeeEmployeePost", b =>
{
b.HasOne("DatabaseCore.Models.Department.Employee", "Employee")
@ -414,6 +499,11 @@ namespace DatabaseCore.Migrations
b.Navigation("User");
});
modelBuilder.Entity("DatabaseCore.Models.Department.DisciplineBlock", b =>
{
b.Navigation("Disciplines");
});
modelBuilder.Entity("DatabaseCore.Models.Department.Employee", b =>
{
b.Navigation("Classrooms");

View File

@ -6,7 +6,7 @@ using System.Runtime.Serialization;
namespace DatabaseCore.Models.Department
{
/// <summary>
/// Класс, описывающий аудиторию в системе
/// Класс, описывающий аудиторию кафедры
/// </summary>
[DataContract]
[EntityDescription("Classroom", "Аудитрия кафедры")]

View File

@ -0,0 +1,44 @@
using ModuleTools.Attributes;
using ModuleTools.Interfaces;
using System;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
namespace DatabaseCore.Models.Department
{
/// <summary>
/// Класс, описывающий дисципилну кафедры
/// </summary>
[DataContract]
[EntityDescription("Discipline", "Дисципилна кафедры")]
[EntityDependency("DisciplineBlock", "EmployeeId", "Сотрудник, отвечающий за аудиторию")]
public class Discipline : BaseEntity, IEntitySecurityExtenstion<Discipline>
{
[DataMember]
[Required(ErrorMessage = "required")]
[MapConfiguration("DisciplineBlockId")]
public Guid DisciplineBlockId { get; set; }
[DataMember]
[Required(ErrorMessage = "required")]
[MapConfiguration("DisciplineName")]
public string DisciplineName { get; set; }
[DataMember]
[MapConfiguration("DisciplineShortName")]
public string DisciplineShortName { get; set; }
[MapConfiguration("DisciplineBlueAsteriskName")]
public string DisciplineBlueAsteriskName { get; set; }
//-------------------------------------------------------------------------
public virtual DisciplineBlock DisciplineBlock { get; set; }
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
public Discipline SecurityCheck(Discipline entity, bool allowFullData) => entity;
}
}

View File

@ -0,0 +1,45 @@
using ModuleTools.Attributes;
using ModuleTools.Interfaces;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace DatabaseCore.Models.Department
{
/// <summary>
/// Класс, описывающий блок дисциплин
/// </summary>
[DataContract]
[EntityDescription("DisciplineBlock", "Аудитрия кафедры")]
public class DisciplineBlock : BaseEntity, IEntitySecurityExtenstion<DisciplineBlock>
{
[DataMember]
[Required(ErrorMessage = "required")]
[MapConfiguration("Title")]
public string Title { get; set; }
[DataMember]
[MapConfiguration("DisciplineBlockUseForGrouping")]
public bool DisciplineBlockUseForGrouping { get; set; }
[DataMember]
[MapConfiguration("DisciplineBlockOrder")]
public int DisciplineBlockOrder { get; set; }
[DataMember]
[MapConfiguration("DisciplineBlockBlueAsteriskName")]
public string DisciplineBlockBlueAsteriskName { get; set; }
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
[ForeignKey("DisciplineBlockId")]
public virtual List<Discipline> Disciplines { get; set; }
//-------------------------------------------------------------------------
public DisciplineBlock SecurityCheck(DisciplineBlock entity, bool allowFullData) => entity;
}
}

View File

@ -7,11 +7,11 @@ using System.Runtime.Serialization;
namespace DatabaseCore.Models.Department
{
/// <summary>
/// Класс, описывающий сотрудника в системе
/// </summary>
[DataContract]
[EntityDescription("Employee", "Сотрудника в системе")]
/// <summary>
/// Класс, описывающий сотрудника кафедры
/// </summary>
[DataContract]
[EntityDescription("Employee", "Сотрудника кафедры")]
public class Employee : BaseEntity, IEntitySecurityExtenstion<Employee>
{
[DataMember]

View File

@ -6,10 +6,10 @@ using System.Runtime.Serialization;
namespace DatabaseCore.Models.Department
{
/// <summary>
/// Класс, описывающий связь сотрудника и должность в системе
/// Класс, описывающий связь сотрудника и должность кафедры
/// </summary>
[DataContract]
[EntityDescription("EmployeeEmployeePost", "Связь сотрудника и должность в системе")]
[EntityDescription("EmployeeEmployeePost", "Связь сотрудника и должность кафедры")]
[EntityDependency("EmployeePost", "EmployeePostId", "К какой должности относится сотрудник")]
[EntityDependency("Employee", "EmployeeId", "К какой должности относится сотрудник")]
public class EmployeeEmployeePost : BaseEntity, IEntitySecurityExtenstion<EmployeeEmployeePost>

View File

@ -7,10 +7,10 @@ using System.Runtime.Serialization;
namespace DatabaseCore.Models.Department
{
/// <summary>
/// Класс, описывающий должность сотрудника в системе
/// Класс, описывающий должность сотрудника кафедры
/// </summary>
[DataContract]
[EntityDescription("EmployeePost", "Должность сотрудника в системе")]
[EntityDescription("EmployeePost", "Должность сотрудника кафедры")]
public class EmployeePost : BaseEntity, IEntitySecurityExtenstion<EmployeePost>
{
[DataMember]

View File

@ -249,9 +249,12 @@ namespace DesktopTools.Controls
toolStripLabelCountRecords.Visible = toolStripTextBoxCountRecords.Visible = toolStripButtonNext.Visible = false;
toolStripComboBoxPageNames.Items.AddRange(config.PageNamesForPagination.ToArray());
toolStripComboBoxPageNames.SelectedIndexChanged -= ToolStripComboBoxPageNamesSelectedIndexChanged;
toolStripComboBoxPageNames.SelectedIndex = 0;
toolStripComboBoxPageNames.SelectedIndexChanged += ToolStripComboBoxPageNamesSelectedIndexChanged;
if (toolStripComboBoxPageNames.Items.Count > 0)
{
toolStripComboBoxPageNames.SelectedIndexChanged -= ToolStripComboBoxPageNamesSelectedIndexChanged;
toolStripComboBoxPageNames.SelectedIndex = 0;
toolStripComboBoxPageNames.SelectedIndexChanged += ToolStripComboBoxPageNamesSelectedIndexChanged;
}
toolStripComboBoxPageNames.Tag = config.ParentPropertyName;
}
}

View File

@ -26,16 +26,16 @@
#region База
Кафедра = 100,
Сотрудники = 101,
Сотрудники = 101, // + должности
Аудитории = 102,
Дисциплины = 103, // + Блоки дисциплин
Направления = 102,
Преподаватели = 103, // + должности, звания
Дисциплины = 104, // + Блоки дисциплин
Группы = 105, //
Студенты = 106,

View File

@ -0,0 +1,56 @@
using ModuleTools.Attributes;
using ModuleTools.BindingModels;
using System;
using System.ComponentModel.DataAnnotations;
namespace DepartmentBusinessLogic.BindingModels
{
/// <summary>
/// Получение дисциплины
/// </summary>
public class DisciplineGetBindingModel : GetBindingModel
{
/// <summary>
/// Выбрка по блокам
/// </summary>
public Guid? DisciplineBlockId { get; set; }
/// <summary>
/// Поиск по названию
/// </summary>
public string DisciplineName { get; set; }
}
/// <summary>
/// Сохранение дисциплины
/// </summary>
public class DisciplineSetBindingModel : SetBindingModel
{
[Required(ErrorMessage = "required")]
[MapConfiguration("DisciplineBlockId")]
public Guid DisciplineBlockId { get; set; }
[Required(ErrorMessage = "required")]
[MapConfiguration("DisciplineName")]
public string DisciplineName { get; set; }
[Required(ErrorMessage = "required")]
[MapConfiguration("DisciplineShortName")]
public string DisciplineShortName { get; set; }
[MapConfiguration("DisciplineBlueAsteriskName")]
public string DisciplineBlueAsteriskName { get; set; }
/// <summary>
/// Используется только в расчетах, не сохраняется
/// </summary>
[MapConfiguration("DisciplineBlueAsteriskCode")]
public string DisciplineBlueAsteriskCode { get; set; }
/// <summary>
/// Используется только в расчетах, не сохраняется
/// </summary>
[MapConfiguration("DisciplineBlueAsteriskPracticCode")]
public string DisciplineBlueAsteriskPracticCode { get; set; }
}
}

View File

@ -0,0 +1,39 @@
using ModuleTools.Attributes;
using ModuleTools.BindingModels;
using System.ComponentModel.DataAnnotations;
namespace DepartmentBusinessLogic.BindingModels
{
/// <summary>
/// Получение блока дисциплин
/// </summary>
public class DisciplineBlockGetBindingModel : GetBindingModel
{
}
/// <summary>
/// Сохранение блока дисциплин
/// </summary>
public class DisciplineBlockSetBindingModel : SetBindingModel
{
[Required(ErrorMessage = "required")]
[MapConfiguration("Title")]
public string Title { get; set; }
[MapConfiguration("DisciplineBlockUseForGrouping")]
public bool DisciplineBlockUseForGrouping { get; set; }
[Required(ErrorMessage = "required")]
[MapConfiguration("DisciplineBlockOrder")]
public int DisciplineBlockOrder { get; set; }
/// <summary>
/// Используется только в расчетах, не сохраняется
/// </summary>
[MapConfiguration("DisciplineBlockBlueAsteriskCode")]
public string DisciplineBlockBlueAsteriskCode { get; set; }
[MapConfiguration("DisciplineBlockBlueAsteriskName")]
public string DisciplineBlockBlueAsteriskName { get; set; }
}
}

View File

@ -0,0 +1,16 @@
using DepartmentBusinessLogic.BindingModels;
using DepartmentBusinessLogic.Interfaces;
using DepartmentBusinessLogic.ViewModels;
using ModuleTools.BusinessLogics;
using ModuleTools.Enums;
namespace DepartmentBusinessLogic.BusinessLogics
{
/// <summary>
/// Логика работы с блоками дисциплин
/// </summary>
public class DisciplineBlockBusinessLogic : GenericBusinessLogic<DisciplineBlockGetBindingModel, DisciplineBlockSetBindingModel, DisciplineBlockListViewModel, DisciplineBlockViewModel>
{
public DisciplineBlockBusinessLogic(IDisciplineBlockService service) : base(service, "Аудитории", AccessOperation.Дисциплины) { }
}
}

View File

@ -0,0 +1,16 @@
using DepartmentBusinessLogic.BindingModels;
using DepartmentBusinessLogic.Interfaces;
using DepartmentBusinessLogic.ViewModels;
using ModuleTools.BusinessLogics;
using ModuleTools.Enums;
namespace DepartmentBusinessLogic.BusinessLogics
{
/// <summary>
/// Логика работы с дисциплинами
/// </summary>
public class DisciplineBusinessLogic : GenericBusinessLogic<DisciplineGetBindingModel, DisciplineSetBindingModel, DisciplineListViewModel, DisciplineViewModel>
{
public DisciplineBusinessLogic(IDisciplineService service) : base(service, "Аудитории", AccessOperation.Дисциплины) { }
}
}

View File

@ -0,0 +1,10 @@
using DepartmentBusinessLogic.BindingModels;
using ModuleTools.Interfaces;
namespace DepartmentBusinessLogic.Interfaces
{
/// <summary>
/// Хранение блоков дисциплин
/// </summary>
public interface IDisciplineBlockService : IGenerticEntityService<DisciplineBlockGetBindingModel, DisciplineBlockSetBindingModel> { }
}

View File

@ -0,0 +1,10 @@
using DepartmentBusinessLogic.BindingModels;
using ModuleTools.Interfaces;
namespace DepartmentBusinessLogic.Interfaces
{
/// <summary>
/// Хранение дисциплин
/// </summary>
public interface IDisciplineService : IGenerticEntityService<DisciplineGetBindingModel, DisciplineSetBindingModel> { }
}

View File

@ -0,0 +1,40 @@
using ModuleTools.Attributes;
using ModuleTools.Enums;
using ModuleTools.ViewModels;
namespace DepartmentBusinessLogic.ViewModels
{
/// <summary>
/// Список блоков дисциплин
/// </summary>
public class DisciplineBlockListViewModel : ListViewModel<DisciplineBlockViewModel> { }
/// <summary>
/// Элемент блок дисциплины
/// </summary>
[ViewModelControlElementClass(HaveDependenceEntities = true, Width = 800, Height = 500)]
[ViewModelControlElementDependenceEntity(Title = "Дисципилны", Order = 1, ParentPropertyName = "DisciplineBlockId",
ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlDisciplineList, DepartmentWindowsDesktop")]
public class DisciplineBlockViewModel : ElementViewModel
{
[ViewModelControlListProperty("Название блока")]
[ViewModelControlElementProperty("Название блока", ControlType.ControlString, MustHaveValue = true)]
[MapConfiguration("Title")]
public string Title { get; set; }
[ViewModelControlElementProperty("Используется для группровки в расчетах", ControlType.ControlBool, MustHaveValue = true)]
[MapConfiguration("DisciplineBlockUseForGrouping")]
public bool DisciplineBlockUseForGrouping { get; set; }
[ViewModelControlListProperty("Порядок", ColumnWidth = 100)]
[ViewModelControlElementProperty("Порядок", ControlType.ControlInt, MustHaveValue = true)]
[MapConfiguration("DisciplineBlockOrder")]
public int DisciplineBlockOrder { get; set; }
[ViewModelControlElementProperty("Назв. в планах", ControlType.ControlString)]
[MapConfiguration("DisciplineBlockBlueAsteriskName")]
public string DisciplineBlockBlueAsteriskName { get; set; }
public override string ToString() => Title;
}
}

View File

@ -0,0 +1,46 @@
using ModuleTools.Attributes;
using ModuleTools.Enums;
using ModuleTools.ViewModels;
using System;
namespace DepartmentBusinessLogic.ViewModels
{
class DisciplineViewModels
{
}
/// <summary>
/// Список дисциплин
/// </summary>
public class DisciplineListViewModel : ListViewModel<DisciplineViewModel> { }
/// <summary>
/// Элемент дисциплина
/// </summary>
[ViewModelControlElementClass()]
public class DisciplineViewModel : ElementViewModel
{
[ViewModelControlElementProperty("Блок дисциплин", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlDisciplineBlockList, DepartmentWindowsDesktop")]
[MapConfiguration("DisciplineBlockId")]
public Guid DisciplineBlockId { get; set; }
[ViewModelControlListProperty("Блок дисциплин")]
[MapConfiguration("DisciplineBlock.Title", IsDifficle = true)]
public string DisciplineBlockTitle { get; set; }
[ViewModelControlListProperty("Название дисциплины")]
[ViewModelControlElementProperty("Название дисциплины", ControlType.ControlString, MustHaveValue = true)]
[MapConfiguration("DisciplineName")]
public string DisciplineName { get; set; }
[ViewModelControlListProperty("Краткое название дисциплины")]
[ViewModelControlElementProperty("Краткое нисциплины", ControlType.ControlString, MustHaveValue = true)]
[MapConfiguration("DisciplineShortName")]
public string DisciplineShortName { get; set; }
[ViewModelControlElementProperty("Название в планах", ControlType.ControlString)]
[MapConfiguration("DisciplineBlueAsteriskName")]
public string DisciplineBlueAsteriskName { get; set; }
public override string ToString() => DisciplineName;
}
}

View File

@ -16,16 +16,16 @@ namespace DepartmentBusinessLogic.ViewModels
[ViewModelControlElementClass()]
public class EmployeeEmployeePostViewModel : ElementViewModel
{
[ViewModelControlElementProperty("Сотрудник", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlEmployeeList, DepartmentWindowsDesktop")]
[MapConfiguration("EmployeeId", AllowCopyWithoutRigth = false)]
[ViewModelControlElementProperty("Сотрудник", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlEmployeeList, DepartmentWindowsDesktop")]
public Guid EmployeeId { get; set; }
public Guid EmployeeId { get; set; }
[ViewModelControlListProperty("Сотрудник")]
[MapConfiguration("Employee.LastName", IsDifficle = true)]
public string EmployeeName { get; set; }
[MapConfiguration("EmployeePostId")]
[ViewModelControlElementProperty("Должность", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlEmployeePostList, DepartmentWindowsDesktop")]
[MapConfiguration("EmployeePostId")]
public Guid EmployeePostId { get; set; }
[ViewModelControlListProperty("Должность")]

View File

@ -13,8 +13,10 @@ namespace DepartmentDatabaseImplementation
DependencyManager.Instance.RegisterType<IEmployeeService, EmployeeService>();
DependencyManager.Instance.RegisterType<IEmployeeEmployeePostService, EmployeeEmployeePostService>();
DependencyManager.Instance.RegisterType<IClassroomService, ClassroomService>();
DependencyManager.Instance.RegisterType<IDisciplineBlockService, DisciplineBlockService>();
DependencyManager.Instance.RegisterType<IDisciplineService, DisciplineService>();
}
}
}

View File

@ -0,0 +1,140 @@
using DatabaseCore;
using DatabaseCore.Models.Department;
using DepartmentBusinessLogic.BindingModels;
using DepartmentBusinessLogic.Interfaces;
using DepartmentBusinessLogic.ViewModels;
using ModuleTools.BusinessLogics;
using ModuleTools.Enums;
using ModuleTools.Models;
using System;
using System.Linq;
namespace DepartmentDatabaseImplementation.Implementations
{
/// <summary>
/// Реализация IDisciplineBlockService
/// </summary>
public class DisciplineBlockService : IDisciplineBlockService
{
public OperationResultModel Create(DisciplineBlockSetBindingModel model)
{
using var context = DatabaseManager.GetContext;
var exsistEntity = context.DisciplineBlocks.FirstOrDefault(x => x.Title == model.Title);
if (exsistEntity == null)
{
var entity = Mapper.MapToClass<DisciplineBlockSetBindingModel, DisciplineBlock>(model, true);
context.DisciplineBlocks.Add(entity);
context.SaveChanges();
return OperationResultModel.Success(Mapper.MapToClass<DisciplineBlock, DisciplineBlockViewModel>(entity, true));
}
else
{
if (exsistEntity.IsDeleted)
{
exsistEntity = Mapper.MapToClass(model, exsistEntity, true);
exsistEntity.IsDeleted = false;
context.SaveChanges();
return OperationResultModel.Success(Mapper.MapToClass<DisciplineBlock, DisciplineBlockViewModel>(exsistEntity, true));
}
else
{
return OperationResultModel.Error("Error:", "Элемент уже существует", ResultServiceStatusCode.ExsistItem);
}
}
}
public OperationResultModel Delete(DisciplineBlockGetBindingModel model)
{
using var context = DatabaseManager.GetContext;
using var transaction = context.Database.BeginTransaction();
try
{
var entity = context.DisciplineBlocks.FirstOrDefault(x => x.Id == model.Id);
if (entity == null)
{
return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound);
}
else if (entity.IsDeleted)
{
return OperationResultModel.Error("Error:", "Элемент был удален", ResultServiceStatusCode.WasDelete);
}
var disciplines = context.Disciplines.Where(x => x.DisciplineBlockId == model.Id);
if (disciplines.Any())
{
return OperationResultModel.Error("Error:", "Есть дисциплины, относящиеся к этому блоку", ResultServiceStatusCode.ExsistItem);
}
entity.IsDeleted = true;
entity.DateDelete = DateTime.Now;
context.SaveChanges();
transaction.Commit();
}
catch (Exception)
{
transaction.Rollback();
throw;
}
return OperationResultModel.Success(true);
}
public OperationResultModel Read(DisciplineBlockGetBindingModel model)
{
int countPages = 0;
using var context = DatabaseManager.GetContext;
// для одной записи
if (model.Id.HasValue)
{
var entity = context.DisciplineBlocks.FirstOrDefault(x => x.Id == model.Id.Value);
if (entity == null)
{
return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound);
}
return OperationResultModel.Success(Mapper.MapToClass<DisciplineBlock, DisciplineBlockViewModel>(entity, model.HaveRight));
}
var query = context.DisciplineBlocks.Where(x => !x.IsDeleted).AsQueryable();
query = query.OrderBy(x => x.DisciplineBlockOrder);
if (model.PageNumber.HasValue && model.PageSize.HasValue)
{
countPages = (int)Math.Ceiling((double)query.Count() / model.PageSize.Value);
query = query
.Skip(model.PageSize.Value * model.PageNumber.Value)
.Take(model.PageSize.Value);
}
var result = new DisciplineBlockListViewModel
{
MaxCount = countPages,
List = query.Select(x => Mapper.MapToClass<DisciplineBlock, DisciplineBlockViewModel>(x, model.HaveRight)).ToList()
};
return OperationResultModel.Success(result);
}
public OperationResultModel Update(DisciplineBlockSetBindingModel model)
{
using var context = DatabaseManager.GetContext;
var entity = context.DisciplineBlocks.FirstOrDefault(x => x.Id == model.Id);
if (entity == null)
{
return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound);
}
else if (entity.IsDeleted)
{
return OperationResultModel.Error("Error:", "Элемент был удален", ResultServiceStatusCode.WasDelete);
}
entity = Mapper.MapToClass(model, entity, true);
context.SaveChanges();
return OperationResultModel.Success(Mapper.MapToClass<DisciplineBlock, DisciplineBlockViewModel>(entity, true));
}
}
}

View File

@ -0,0 +1,137 @@
using DatabaseCore;
using DatabaseCore.Models.Department;
using DepartmentBusinessLogic.BindingModels;
using DepartmentBusinessLogic.Interfaces;
using DepartmentBusinessLogic.ViewModels;
using Microsoft.EntityFrameworkCore;
using ModuleTools.BusinessLogics;
using ModuleTools.Enums;
using ModuleTools.Extensions;
using ModuleTools.Models;
using System;
using System.Linq;
namespace DepartmentDatabaseImplementation.Implementations
{
/// <summary>
/// Реализация IDisciplineService
/// </summary>
public class DisciplineService : IDisciplineService
{
public OperationResultModel Create(DisciplineSetBindingModel model)
{
using var context = DatabaseManager.GetContext;
var exsistEntity = context.Disciplines.FirstOrDefault(x => x.DisciplineName == model.DisciplineName);
if (exsistEntity == null)
{
var entity = Mapper.MapToClass<DisciplineSetBindingModel, Discipline>(model, true);
context.Disciplines.Add(entity);
context.SaveChanges();
return OperationResultModel.Success(Mapper.MapToClass<Discipline, DisciplineViewModel>(entity, true));
}
else
{
if (exsistEntity.IsDeleted)
{
exsistEntity = Mapper.MapToClass(model, exsistEntity, true);
exsistEntity.IsDeleted = false;
context.SaveChanges();
return OperationResultModel.Success(Mapper.MapToClass<Discipline, DisciplineViewModel>(exsistEntity, true));
}
else
{
return OperationResultModel.Error("Error:", "Элемент уже существует", ResultServiceStatusCode.ExsistItem);
}
}
}
public OperationResultModel Delete(DisciplineGetBindingModel model)
{
using var context = DatabaseManager.GetContext;
var entity = context.Disciplines.FirstOrDefault(x => x.Id == model.Id);
if (entity == null)
{
return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound);
}
else if (entity.IsDeleted)
{
return OperationResultModel.Error("Error:", "Элемент был удален", ResultServiceStatusCode.WasDelete);
}
entity.IsDeleted = true;
entity.DateDelete = DateTime.Now;
context.SaveChanges();
return OperationResultModel.Success(true);
}
public OperationResultModel Read(DisciplineGetBindingModel model)
{
int countPages = 0;
using var context = DatabaseManager.GetContext;
// для одной записи
if (model.Id.HasValue)
{
var entity = context.Disciplines.FirstOrDefault(x => x.Id == model.Id.Value);
if (entity == null)
{
return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound);
}
return OperationResultModel.Success(Mapper.MapToClass<Discipline, DisciplineViewModel>(entity, model.HaveRight));
}
var query = context.Disciplines.Where(x => !x.IsDeleted).AsQueryable();
if (model.DisciplineName.IsNotEmpty())
{
query = query.Where(x => x.DisciplineName.Contains(model.DisciplineName));
}
if (model.DisciplineBlockId.HasValue)
{
query = query.Where(x => x.DisciplineBlockId == model.DisciplineBlockId.Value);
}
query = query.OrderBy(x => x.DisciplineBlock.DisciplineBlockOrder).ThenBy(x => x.DisciplineName);
if (model.PageNumber.HasValue && model.PageSize.HasValue)
{
countPages = (int)Math.Ceiling((double)query.Count() / model.PageSize.Value);
query = query
.Skip(model.PageSize.Value * model.PageNumber.Value)
.Take(model.PageSize.Value);
}
query = query.Include(x => x.DisciplineBlock);
var result = new DisciplineListViewModel
{
MaxCount = countPages,
List = query.Select(x => Mapper.MapToClass<Discipline, DisciplineViewModel>(x, model.HaveRight)).ToList()
};
return OperationResultModel.Success(result);
}
public OperationResultModel Update(DisciplineSetBindingModel model)
{
using var context = DatabaseManager.GetContext;
var entity = context.Disciplines.FirstOrDefault(x => x.Id == model.Id);
if (entity == null)
{
return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound);
}
else if (entity.IsDeleted)
{
return OperationResultModel.Error("Error:", "Элемент был удален", ResultServiceStatusCode.WasDelete);
}
entity = Mapper.MapToClass(model, entity, true);
context.SaveChanges();
return OperationResultModel.Success(Mapper.MapToClass<Discipline, DisciplineViewModel>(entity, true));
}
}
}

View File

@ -34,7 +34,9 @@ namespace DepartmentWindowsDesktop
{
new ControlEmployeePostList(),
new ControlEmployeeList(),
new ControlClassroomList()
new ControlClassroomList(),
new ControlDisciplineBlockList(),
new ControlDisciplineList()
};
foreach (var cntrl in _controls)

View File

@ -11,6 +11,9 @@ using System.Collections.Generic;
namespace DepartmentWindowsDesktop.EntityControls
{
/// <summary>
/// Реализация контрола для списка аудиторий
/// </summary>
public partial class ControlClassroomList :
GenericControlEntityList<ClassroomGetBindingModel, ClassroomSetBindingModel, ClassroomListViewModel, ClassroomViewModel, ClassroomBusinessLogic>,
IGenericControlEntityList<ClassroomListViewModel, ClassroomViewModel>

View File

@ -0,0 +1,33 @@

namespace DepartmentWindowsDesktop.EntityControls
{
partial class ControlDisciplineBlockElement
{
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
}
#endregion
}
}

View File

@ -0,0 +1,27 @@
using DepartmentBusinessLogic.BindingModels;
using DepartmentBusinessLogic.BusinessLogics;
using DepartmentBusinessLogic.ViewModels;
using DesktopTools.Controls;
using DesktopTools.Interfaces;
using System;
namespace DepartmentWindowsDesktop.EntityControls
{
/// <summary>
/// Реализация контрола для блока дисциплин
/// </summary>
public partial class ControlDisciplineBlockElement :
GenericControlEntityElement<DisciplineBlockGetBindingModel, DisciplineBlockSetBindingModel, DisciplineBlockListViewModel, DisciplineBlockViewModel, DisciplineBlockBusinessLogic>,
IGenericControlEntityElement
{
public ControlDisciplineBlockElement()
{
InitializeComponent();
Title = "Блок дисципилн";
ControlId = new Guid("8e2032c5-1412-4ccd-855c-f0b0836e3599");
_genericControlViewEntityElement = this;
}
public IControl GetInstanceGenericControl() => new ControlDisciplineBlockElement() { ControlId = Guid.NewGuid() };
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,33 @@

namespace DepartmentWindowsDesktop.EntityControls
{
partial class ControlDisciplineBlockList
{
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
}
#endregion
}
}

View File

@ -0,0 +1,50 @@
using DepartmentBusinessLogic.BindingModels;
using DepartmentBusinessLogic.BusinessLogics;
using DepartmentBusinessLogic.ViewModels;
using DesktopTools.Controls;
using DesktopTools.Enums;
using DesktopTools.Interfaces;
using DesktopTools.Models;
using ModuleTools.Enums;
using System;
using System.Collections.Generic;
namespace DepartmentWindowsDesktop.EntityControls
{
/// <summary>
/// Реализация контрола для списка блоков дисциплин
/// </summary>
public partial class ControlDisciplineBlockList :
GenericControlEntityList<DisciplineBlockGetBindingModel, DisciplineBlockSetBindingModel, DisciplineBlockListViewModel, DisciplineBlockViewModel, DisciplineBlockBusinessLogic>,
IGenericControlEntityList<DisciplineBlockListViewModel, DisciplineBlockViewModel>
{
public ControlDisciplineBlockList()
{
InitializeComponent();
Title = "Блоки дисциплин";
ControlId = new Guid("1c115bda-fa08-4127-ac4b-daba79d65628");
AccessOperation = AccessOperation.Дисциплины;
ControlViewEntityElement = new ControlDisciplineBlockElement();
_genericControlViewEntityList = this;
}
public IControl GetInstanceGenericControl() => new ControlDisciplineBlockList() { ControlId = Guid.NewGuid() };
public ControlViewEntityListConfiguration GetConfigControl() => new()
{
PaginationOn = false,
HideToolStripButton = new List<ToolStripButtonListNames>
{
ToolStripButtonListNames.toolStripButtonSearch
}
};
public DisciplineBlockListViewModel GetDataForControl() => _businessLogic.GetList(new DisciplineBlockGetBindingModel());
public DisciplineBlockListViewModel GetDataFromParentForControl(Guid id) => throw new NotImplementedException();
public DisciplineBlockListViewModel GetDataWithPageNameForControl(string key) => throw new NotImplementedException();
public DisciplineBlockListViewModel GetDataWithPageNumberForControl(int page, int count) => throw new NotImplementedException();
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,33 @@

namespace DepartmentWindowsDesktop.EntityControls
{
partial class ControlDisciplineElement
{
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
}
#endregion
}
}

View File

@ -0,0 +1,27 @@
using DepartmentBusinessLogic.BindingModels;
using DepartmentBusinessLogic.BusinessLogics;
using DepartmentBusinessLogic.ViewModels;
using DesktopTools.Controls;
using DesktopTools.Interfaces;
using System;
namespace DepartmentWindowsDesktop.EntityControls
{
/// <summary>
/// Реализация контрола для дисциплины
/// </summary>
public partial class ControlDisciplineElement :
GenericControlEntityElement<DisciplineGetBindingModel, DisciplineSetBindingModel, DisciplineListViewModel, DisciplineViewModel, DisciplineBusinessLogic>,
IGenericControlEntityElement
{
public ControlDisciplineElement()
{
InitializeComponent();
Title = "Дисципилна";
ControlId = new Guid("8905d288-48c2-4bee-bf5e-2115bbccf6a7");
_genericControlViewEntityElement = this;
}
public IControl GetInstanceGenericControl() => new ControlDisciplineElement() { ControlId = Guid.NewGuid() };
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,33 @@

namespace DepartmentWindowsDesktop.EntityControls
{
partial class ControlDisciplineList
{
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
}
#endregion
}
}

View File

@ -0,0 +1,92 @@
using DepartmentBusinessLogic.BindingModels;
using DepartmentBusinessLogic.BusinessLogics;
using DepartmentBusinessLogic.ViewModels;
using DesktopTools.BaseControls;
using DesktopTools.Controls;
using DesktopTools.Interfaces;
using DesktopTools.Models;
using ModuleTools.BusinessLogics;
using ModuleTools.Enums;
using System;
using System.Linq;
namespace DepartmentWindowsDesktop.EntityControls
{
public partial class ControlDisciplineList :
GenericControlEntityList<DisciplineGetBindingModel, DisciplineSetBindingModel, DisciplineListViewModel, DisciplineViewModel, DisciplineBusinessLogic>,
IGenericControlEntityList<DisciplineListViewModel, DisciplineViewModel>
{
private readonly DisciplineBlockBusinessLogic _disciplineBlockBusinessLogic;
public ControlDisciplineList()
{
InitializeComponent();
_disciplineBlockBusinessLogic = DependencyManager.Instance.Resolve<DisciplineBlockBusinessLogic>();
Title = "Дисциплины";
ControlId = new Guid("1731f50b-b20b-44c4-aa56-b335764fae7a");
AccessOperation = AccessOperation.Дисциплины;
ControlViewEntityElement = new ControlDisciplineElement();
_genericControlViewEntityList = this;
FillSearchPanel();
}
public IControl GetInstanceGenericControl() => new ControlDisciplineList() { ControlId = Guid.NewGuid() };
public ControlViewEntityListConfiguration GetConfigControl() => new()
{
PaginationOn = true,
PageNamesForPagination = _disciplineBlockBusinessLogic.GetList(new DisciplineBlockGetBindingModel())?.List?.Select(x =>
new PageNamesForPaginationModel
{
Key = x.Id.ToString(),
Value = x.Title
})?.ToList(),
ParentPropertyName = "DisciplineBlockId"
};
public DisciplineListViewModel GetDataForControl()
{
var model = new DisciplineGetBindingModel();
if (_searchValues != null)
{
var cntrl = _searchValues.FirstOrDefault(x => x.Name == "UserNameForSearch");
if (cntrl != default)
{
model.DisciplineName = cntrl.Value.ToString();
}
}
return _businessLogic.GetList(model);
}
public DisciplineListViewModel GetDataFromParentForControl(Guid id)
{
var model = new DisciplineGetBindingModel { DisciplineBlockId = id };
if (_searchValues != null)
{
var cntrl = _searchValues.FirstOrDefault(x => x.Name == "UserNameForSearch");
if (cntrl != default)
{
model.DisciplineName = cntrl.Value.ToString();
}
}
return _businessLogic.GetList(model);
}
public DisciplineListViewModel GetDataWithPageNameForControl(string key) => throw new NotImplementedException();
public DisciplineListViewModel GetDataWithPageNumberForControl(int page, int count) => throw new NotImplementedException();
private void FillSearchPanel()
{
var control = new BaseControlString("DisciplineNameForSearch", false, false, 0)
{
Location = new System.Drawing.Point(10, 10),
Size = new System.Drawing.Size(400, 23),
Name = "SearchDisciplineName",
TabIndex = 0
};
control.SetTitleWidth(control.SetTitle("Название:"));
panelSearchControls.Controls.Add(control);
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -11,6 +11,9 @@ using System.Collections.Generic;
namespace DepartmentWindowsDesktop.EntityControls
{
/// <summary>
/// Реализация контрола для списка сотрудников
/// </summary>
public partial class ControlEmployeeList :
GenericControlEntityList<EmployeeGetBindingModel, EmployeeSetBindingModel, EmployeeListViewModel, EmployeeViewModel, EmployeeBusinessLogic>,
IGenericControlEntityList<EmployeeListViewModel, EmployeeViewModel>