From 4b004a26287cc1616540facc03d6730e88dfcce9 Mon Sep 17 00:00:00 2001 From: maksim Date: Tue, 26 Nov 2024 21:24:08 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9E=D1=85=20=D1=83=D0=B6=20=D1=8D=D1=82?= =?UTF-8?q?=D0=B8=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B8=20=D0=B2=20Visual?= =?UTF-8?q?Studio...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogic/EmployeeLogic.cs | 162 +++--------------- .../EmployeeManagmentBusinessLogic.csproj | 15 ++ .../BusinessLogicContracts/IEmployeeLogic.cs | 8 +- .../EmployeeManagmentContracts.csproj | 14 ++ .../EmployeeManagementDbContext .cs | 2 +- .../EmployeeManagmentDataBaseImplement.csproj | 14 +- .../Implements/VacationStorage.cs | 12 +- ... 20241124115213_InitMigration.Designer.cs} | 71 ++++---- ...ion.cs => 20241124115213_InitMigration.cs} | 81 ++++----- ...mployeeManagementDbContextModelSnapshot.cs | 67 +++++--- .../EmployeeManagmentDataModels.csproj | 14 ++ EmployeeManagmentView/App.xaml | 4 +- EmployeeManagmentView/App.xaml.cs | 18 +- .../EmployeeManagmentView.csproj | 15 +- EmployeeManagmentView/MainWindow.xaml | 5 - EmployeeManagmentView/MainWindow.xaml.cs | 12 +- .../PhisicalPersonWindow.xaml | 30 ---- .../PhisicalPersonWindow.xaml.cs | 149 ---------------- 18 files changed, 233 insertions(+), 460 deletions(-) rename EmployeeManagmentDataBaseImplement/Migrations/{20241113084724_InitialMigration.Designer.cs => 20241124115213_InitMigration.Designer.cs} (72%) rename EmployeeManagmentDataBaseImplement/Migrations/{20241113084724_InitialMigration.cs => 20241124115213_InitMigration.cs} (52%) delete mode 100644 EmployeeManagmentView/PhisicalPersonWindow.xaml delete mode 100644 EmployeeManagmentView/PhisicalPersonWindow.xaml.cs diff --git a/EmployeeManagmentBusinessLogic/BusinessLogic/EmployeeLogic.cs b/EmployeeManagmentBusinessLogic/BusinessLogic/EmployeeLogic.cs index cab4dee..0414beb 100644 --- a/EmployeeManagmentBusinessLogic/BusinessLogic/EmployeeLogic.cs +++ b/EmployeeManagmentBusinessLogic/BusinessLogic/EmployeeLogic.cs @@ -3,163 +3,53 @@ using System.Linq; using EmployeeManagmentContracts.BindingModels; using EmployeeManagmentContracts.BusinessLogicContracts; using EmployeeManagmentContracts.SearchModels; +using EmployeeManagmentContracts.StoragesContracts; using EmployeeManagmentContracts.ViewModels; using EmployeeManagmentDataBaseImplement; using EmployeeManagmentDataBaseImplement.Models; +using Microsoft.Extensions.Logging; namespace EmployeeManagmentBusinessLogic.BusinessLogic { public class EmployeeLogic : IEmployeeLogic { - private readonly EmployeeManagementDbContext _context; + private readonly ILogger _logger; + private readonly IEmployeeStorage _employeeStorage; - public EmployeeLogic(EmployeeManagementDbContext context) + public EmployeeLogic(ILogger logger, IEmployeeStorage employeeStorage) { - _context = context; + _logger = logger; + _employeeStorage = employeeStorage; } - public void CreateOrUpdate(EmployeeBindingModel model) - { - // Проверка на обязательные поля - if (string.IsNullOrWhiteSpace(model.NameJob)) - { - throw new ArgumentException("Job name cannot be empty."); - } - - // Ищем сотрудника по ID, если он уже существует - var employee = _context.Employees.FirstOrDefault(e => e.Id == model.Id); - - if (employee == null) - { - // Создаем нового сотрудника, если не найден - employee = new Employee - { - NameJob = model.NameJob, - StartJob = model.StartJob, - EndJob = model.EndJob, - PartTimeJob = model.PartTimeJob, - Bid = model.Bid, - PhisicalPersonsId = model.PhisicalPersonsId - }; - - try - { - _context.Employees.Add(employee); - _context.SaveChanges(); - } - catch (Exception ex) - { - // Логирование ошибки и обработка - throw new InvalidOperationException("Error while adding new employee: " + ex.Message); - } - } - else - { - // Обновляем данные существующего сотрудника - employee.NameJob = model.NameJob; - employee.StartJob = model.StartJob; - employee.EndJob = model.EndJob; - employee.PartTimeJob = model.PartTimeJob; - employee.Bid = model.Bid; - employee.PhisicalPersonsId = model.PhisicalPersonsId; - - try - { - _context.SaveChanges(); - } - catch (Exception ex) - { - // Логирование ошибки и обработка - throw new InvalidOperationException("Error while updating employee: " + ex.Message); - } - } - } - - public void Delete(int id) { - var employee = _context.Employees.FirstOrDefault(e => e.Id == id); - if (employee != null) - { - // Дополнительная проверка на связи с другими таблицами, если необходимо - if (employee.Salaries.Any() || employee.Vacations.Any()) - { - throw new InvalidOperationException("Employee cannot be deleted because they have related data (e.g., salaries or vacations)."); - } - - _context.Employees.Remove(employee); - _context.SaveChanges(); - } - else - { - throw new KeyNotFoundException($"Employee with ID {id} not found."); - } + throw new NotImplementedException(); } - - public EmployeeViewModel? GetEmployeeById(int id) + public EmployeeViewModel? GetElement(int id) { - var employee = _context.Employees - .Where(e => e.Id == id) - .Select(e => new EmployeeViewModel - { - Id = e.Id, - NameJob = e.NameJob, - StartJob = e.StartJob, - EndJob = e.EndJob, - PartTimeJob = e.PartTimeJob, - Bid = e.Bid, - PhysicalPersonsId = e.PhisicalPersonsId, - PhysicalPersonName = e.PhisicalPerson != null ? e.PhisicalPerson.Name : null - }) - .FirstOrDefault(); - - return employee; + throw new NotImplementedException(); } - public List GetEmployees(EmployeeSearchModel model) + public List GetFilteredList(EmployeeSearchModel model) { - var query = _context.Employees.AsQueryable(); - - if (model.Id.HasValue) - { - query = query.Where(e => e.Id == model.Id.Value); - } - - if (!string.IsNullOrWhiteSpace(model.NameJob)) - { - query = query.Where(e => e.NameJob.Contains(model.NameJob)); - } - - if (model.StartDateFrom.HasValue) - { - query = query.Where(e => e.StartJob >= model.StartDateFrom.Value); - } - - if (model.StartDateTo.HasValue) - { - query = query.Where(e => e.StartJob <= model.StartDateTo.Value); - } - - if (model.Bid.HasValue) - { - query = query.Where(e => e.Bid == model.Bid.Value); - } - - return query - .Select(e => new EmployeeViewModel - { - Id = e.Id, - NameJob = e.NameJob, - StartJob = e.StartJob, - EndJob = e.EndJob, - PartTimeJob = e.PartTimeJob, - Bid = e.Bid, - PhysicalPersonsId = e.PhisicalPersonsId, - PhysicalPersonName = e.PhisicalPerson != null ? e.PhisicalPerson.Name : null - }) - .ToList(); + throw new NotImplementedException(); } + public List GetFullList() + { + throw new NotImplementedException(); + } + + public void Insert(EmployeeViewModel model) + { + throw new NotImplementedException(); + } + + public void Update(EmployeeViewModel model) + { + throw new NotImplementedException(); + } } } diff --git a/EmployeeManagmentBusinessLogic/EmployeeManagmentBusinessLogic.csproj b/EmployeeManagmentBusinessLogic/EmployeeManagmentBusinessLogic.csproj index a0b5388..a70977d 100644 --- a/EmployeeManagmentBusinessLogic/EmployeeManagmentBusinessLogic.csproj +++ b/EmployeeManagmentBusinessLogic/EmployeeManagmentBusinessLogic.csproj @@ -9,6 +9,21 @@ + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/EmployeeManagmentContracts/BusinessLogicContracts/IEmployeeLogic.cs b/EmployeeManagmentContracts/BusinessLogicContracts/IEmployeeLogic.cs index 5239e10..bdecee2 100644 --- a/EmployeeManagmentContracts/BusinessLogicContracts/IEmployeeLogic.cs +++ b/EmployeeManagmentContracts/BusinessLogicContracts/IEmployeeLogic.cs @@ -11,9 +11,11 @@ namespace EmployeeManagmentContracts.BusinessLogicContracts { public interface IEmployeeLogic { - List GetEmployees(EmployeeSearchModel model); - EmployeeViewModel? GetEmployeeById(int id); - void CreateOrUpdate(EmployeeBindingModel model); + List GetFullList(); + List GetFilteredList(EmployeeSearchModel model); + EmployeeViewModel? GetElement(int id); + void Insert(EmployeeViewModel model); + void Update(EmployeeViewModel model); void Delete(int id); } diff --git a/EmployeeManagmentContracts/EmployeeManagmentContracts.csproj b/EmployeeManagmentContracts/EmployeeManagmentContracts.csproj index 555f5a4..1d391d7 100644 --- a/EmployeeManagmentContracts/EmployeeManagmentContracts.csproj +++ b/EmployeeManagmentContracts/EmployeeManagmentContracts.csproj @@ -9,5 +9,19 @@ + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + diff --git a/EmployeeManagmentDataBaseImplement/EmployeeManagementDbContext .cs b/EmployeeManagmentDataBaseImplement/EmployeeManagementDbContext .cs index 95656be..06e4d44 100644 --- a/EmployeeManagmentDataBaseImplement/EmployeeManagementDbContext .cs +++ b/EmployeeManagmentDataBaseImplement/EmployeeManagementDbContext .cs @@ -16,7 +16,7 @@ namespace EmployeeManagmentDataBaseImplement { if (!optionsBuilder.IsConfigured) { - optionsBuilder.UseMySQL("Server=localhost;Port=3306;Database=EmployeeDB;User=root;Password=SuperSecretPasswork2003;"); + optionsBuilder.UseNpgsql("Host=localhost;Database=EmployeeManagementDB;Username=postgres;Password=23859"); } base.OnConfiguring(optionsBuilder); } diff --git a/EmployeeManagmentDataBaseImplement/EmployeeManagmentDataBaseImplement.csproj b/EmployeeManagmentDataBaseImplement/EmployeeManagmentDataBaseImplement.csproj index 95eb660..f607a27 100644 --- a/EmployeeManagmentDataBaseImplement/EmployeeManagmentDataBaseImplement.csproj +++ b/EmployeeManagmentDataBaseImplement/EmployeeManagmentDataBaseImplement.csproj @@ -9,25 +9,21 @@ - runtime; build; native; contentfiles; analyzers; buildtransitive all + runtime; build; native; contentfiles; analyzers; buildtransitive - - runtime; build; native; contentfiles; analyzers; buildtransitive all + runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - + + + diff --git a/EmployeeManagmentDataBaseImplement/Implements/VacationStorage.cs b/EmployeeManagmentDataBaseImplement/Implements/VacationStorage.cs index ddca03c..0873663 100644 --- a/EmployeeManagmentDataBaseImplement/Implements/VacationStorage.cs +++ b/EmployeeManagmentDataBaseImplement/Implements/VacationStorage.cs @@ -9,34 +9,34 @@ using System.Threading.Tasks; namespace EmployeeManagmentDataBaseImplement.Implements { - public class VacationStorage : ISalaryStorage + public class VacationStorage : IVacationStorage { public void Delete(int id) { throw new NotImplementedException(); } - public SalaryViewModel? GetElement(int id) + public VacationViewModel? GetElement(int id) { throw new NotImplementedException(); } - public List GetFilteredList(SalarySearchModel model) + public List GetFilteredList(VacationSearchModel model) { throw new NotImplementedException(); } - public List GetFullList() + public List GetFullList() { throw new NotImplementedException(); } - public void Insert(SalaryViewModel model) + public void Insert(VacationViewModel model) { throw new NotImplementedException(); } - public void Update(SalaryViewModel model) + public void Update(VacationViewModel model) { throw new NotImplementedException(); } diff --git a/EmployeeManagmentDataBaseImplement/Migrations/20241113084724_InitialMigration.Designer.cs b/EmployeeManagmentDataBaseImplement/Migrations/20241124115213_InitMigration.Designer.cs similarity index 72% rename from EmployeeManagmentDataBaseImplement/Migrations/20241113084724_InitialMigration.Designer.cs rename to EmployeeManagmentDataBaseImplement/Migrations/20241124115213_InitMigration.Designer.cs index 55dd2ce..dc8bd25 100644 --- a/EmployeeManagmentDataBaseImplement/Migrations/20241113084724_InitialMigration.Designer.cs +++ b/EmployeeManagmentDataBaseImplement/Migrations/20241124115213_InitMigration.Designer.cs @@ -5,14 +5,15 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace EmployeeManagmentDataBaseImplement.Migrations { [DbContext(typeof(EmployeeManagementDbContext))] - [Migration("20241113084724_InitialMigration")] - partial class InitialMigration + [Migration("20241124115213_InitMigration")] + partial class InitMigration { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -20,32 +21,36 @@ namespace EmployeeManagmentDataBaseImplement.Migrations #pragma warning disable 612, 618 modelBuilder .HasAnnotation("ProductVersion", "8.0.10") - .HasAnnotation("Relational:MaxIdentifierLength", 64); + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); modelBuilder.Entity("EmployeeManagmentDataBaseImplement.Models.Employee", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("Bid") - .HasColumnType("float"); + .HasColumnType("real"); b.Property("EndJob") - .HasColumnType("datetime(6)"); + .HasColumnType("timestamp with time zone"); b.Property("NameJob") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("PartTimeJob") - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("PhisicalPersonsId") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("StartJob") - .HasColumnType("datetime(6)"); + .HasColumnType("timestamp with time zone"); b.HasKey("Id"); @@ -58,33 +63,35 @@ namespace EmployeeManagmentDataBaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("Address") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("Birthday") - .HasColumnType("datetime(6)"); + .HasColumnType("timestamp with time zone"); b.Property("Gender") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("Name") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("Patronymic") - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("Surname") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("Telephone") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.HasKey("Id"); @@ -95,25 +102,27 @@ namespace EmployeeManagmentDataBaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("CountHours") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("Data") - .HasColumnType("datetime(6)"); + .HasColumnType("timestamp with time zone"); b.Property("EmployeesId") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("Passed") - .HasColumnType("tinyint(1)"); + .HasColumnType("boolean"); b.Property("Premium") - .HasColumnType("float"); + .HasColumnType("real"); b.Property("PriceHour") - .HasColumnType("float"); + .HasColumnType("real"); b.HasKey("Id"); @@ -126,19 +135,21 @@ namespace EmployeeManagmentDataBaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("EmployeesId") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("EndData") - .HasColumnType("datetime(6)"); + .HasColumnType("timestamp with time zone"); b.Property("Passed") - .HasColumnType("tinyint(1)"); + .HasColumnType("boolean"); b.Property("StartData") - .HasColumnType("datetime(6)"); + .HasColumnType("timestamp with time zone"); b.HasKey("Id"); diff --git a/EmployeeManagmentDataBaseImplement/Migrations/20241113084724_InitialMigration.cs b/EmployeeManagmentDataBaseImplement/Migrations/20241124115213_InitMigration.cs similarity index 52% rename from EmployeeManagmentDataBaseImplement/Migrations/20241113084724_InitialMigration.cs rename to EmployeeManagmentDataBaseImplement/Migrations/20241124115213_InitMigration.cs index b35e8aa..74efa7b 100644 --- a/EmployeeManagmentDataBaseImplement/Migrations/20241113084724_InitialMigration.cs +++ b/EmployeeManagmentDataBaseImplement/Migrations/20241124115213_InitMigration.cs @@ -1,52 +1,48 @@ using System; using Microsoft.EntityFrameworkCore.Migrations; -using MySql.EntityFrameworkCore.Metadata; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace EmployeeManagmentDataBaseImplement.Migrations { /// - public partial class InitialMigration : Migration + public partial class InitMigration : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { - migrationBuilder.AlterDatabase() - .Annotation("MySQL:Charset", "utf8mb4"); - migrationBuilder.CreateTable( name: "PhysicalPersons", columns: table => new { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), - Name = table.Column(type: "longtext", nullable: false), - Surname = table.Column(type: "longtext", nullable: false), - Patronymic = table.Column(type: "longtext", nullable: true), - Birthday = table.Column(type: "datetime(6)", nullable: false), - Gender = table.Column(type: "longtext", nullable: false), - Address = table.Column(type: "longtext", nullable: false), - Telephone = table.Column(type: "longtext", nullable: false) + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false), + Surname = table.Column(type: "text", nullable: false), + Patronymic = table.Column(type: "text", nullable: true), + Birthday = table.Column(type: "timestamp with time zone", nullable: false), + Gender = table.Column(type: "text", nullable: false), + Address = table.Column(type: "text", nullable: false), + Telephone = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_PhysicalPersons", x => x.Id); - }) - .Annotation("MySQL:Charset", "utf8mb4"); + }); migrationBuilder.CreateTable( name: "Employees", columns: table => new { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), - NameJob = table.Column(type: "longtext", nullable: false), - StartJob = table.Column(type: "datetime(6)", nullable: true), - EndJob = table.Column(type: "datetime(6)", nullable: true), - PartTimeJob = table.Column(type: "longtext", nullable: true), - Bid = table.Column(type: "float", nullable: false), - PhisicalPersonsId = table.Column(type: "int", nullable: false) + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + NameJob = table.Column(type: "text", nullable: false), + StartJob = table.Column(type: "timestamp with time zone", nullable: true), + EndJob = table.Column(type: "timestamp with time zone", nullable: true), + PartTimeJob = table.Column(type: "text", nullable: true), + Bid = table.Column(type: "real", nullable: false), + PhisicalPersonsId = table.Column(type: "integer", nullable: false) }, constraints: table => { @@ -57,21 +53,20 @@ namespace EmployeeManagmentDataBaseImplement.Migrations principalTable: "PhysicalPersons", principalColumn: "Id", onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySQL:Charset", "utf8mb4"); + }); migrationBuilder.CreateTable( name: "Salaries", columns: table => new { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), - CountHours = table.Column(type: "int", nullable: false), - PriceHour = table.Column(type: "float", nullable: false), - Premium = table.Column(type: "float", nullable: true), - Data = table.Column(type: "datetime(6)", nullable: true), - Passed = table.Column(type: "tinyint(1)", nullable: false), - EmployeesId = table.Column(type: "int", nullable: false) + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + CountHours = table.Column(type: "integer", nullable: false), + PriceHour = table.Column(type: "real", nullable: false), + Premium = table.Column(type: "real", nullable: true), + Data = table.Column(type: "timestamp with time zone", nullable: true), + Passed = table.Column(type: "boolean", nullable: false), + EmployeesId = table.Column(type: "integer", nullable: false) }, constraints: table => { @@ -82,19 +77,18 @@ namespace EmployeeManagmentDataBaseImplement.Migrations principalTable: "Employees", principalColumn: "Id", onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySQL:Charset", "utf8mb4"); + }); migrationBuilder.CreateTable( name: "Vacations", columns: table => new { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn), - StartData = table.Column(type: "datetime(6)", nullable: false), - EndData = table.Column(type: "datetime(6)", nullable: false), - Passed = table.Column(type: "tinyint(1)", nullable: false), - EmployeesId = table.Column(type: "int", nullable: false) + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + StartData = table.Column(type: "timestamp with time zone", nullable: false), + EndData = table.Column(type: "timestamp with time zone", nullable: false), + Passed = table.Column(type: "boolean", nullable: false), + EmployeesId = table.Column(type: "integer", nullable: false) }, constraints: table => { @@ -105,8 +99,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations principalTable: "Employees", principalColumn: "Id", onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySQL:Charset", "utf8mb4"); + }); migrationBuilder.CreateIndex( name: "IX_Employees_PhisicalPersonsId", diff --git a/EmployeeManagmentDataBaseImplement/Migrations/EmployeeManagementDbContextModelSnapshot.cs b/EmployeeManagmentDataBaseImplement/Migrations/EmployeeManagementDbContextModelSnapshot.cs index 1c87369..f7d9ffe 100644 --- a/EmployeeManagmentDataBaseImplement/Migrations/EmployeeManagementDbContextModelSnapshot.cs +++ b/EmployeeManagmentDataBaseImplement/Migrations/EmployeeManagementDbContextModelSnapshot.cs @@ -4,6 +4,7 @@ using EmployeeManagmentDataBaseImplement; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable @@ -17,32 +18,36 @@ namespace EmployeeManagmentDataBaseImplement.Migrations #pragma warning disable 612, 618 modelBuilder .HasAnnotation("ProductVersion", "8.0.10") - .HasAnnotation("Relational:MaxIdentifierLength", 64); + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); modelBuilder.Entity("EmployeeManagmentDataBaseImplement.Models.Employee", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("Bid") - .HasColumnType("float"); + .HasColumnType("real"); b.Property("EndJob") - .HasColumnType("datetime(6)"); + .HasColumnType("timestamp with time zone"); b.Property("NameJob") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("PartTimeJob") - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("PhisicalPersonsId") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("StartJob") - .HasColumnType("datetime(6)"); + .HasColumnType("timestamp with time zone"); b.HasKey("Id"); @@ -55,33 +60,35 @@ namespace EmployeeManagmentDataBaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("Address") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("Birthday") - .HasColumnType("datetime(6)"); + .HasColumnType("timestamp with time zone"); b.Property("Gender") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("Name") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("Patronymic") - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("Surname") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.Property("Telephone") .IsRequired() - .HasColumnType("longtext"); + .HasColumnType("text"); b.HasKey("Id"); @@ -92,25 +99,27 @@ namespace EmployeeManagmentDataBaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("CountHours") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("Data") - .HasColumnType("datetime(6)"); + .HasColumnType("timestamp with time zone"); b.Property("EmployeesId") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("Passed") - .HasColumnType("tinyint(1)"); + .HasColumnType("boolean"); b.Property("Premium") - .HasColumnType("float"); + .HasColumnType("real"); b.Property("PriceHour") - .HasColumnType("float"); + .HasColumnType("real"); b.HasKey("Id"); @@ -123,19 +132,21 @@ namespace EmployeeManagmentDataBaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("EmployeesId") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("EndData") - .HasColumnType("datetime(6)"); + .HasColumnType("timestamp with time zone"); b.Property("Passed") - .HasColumnType("tinyint(1)"); + .HasColumnType("boolean"); b.Property("StartData") - .HasColumnType("datetime(6)"); + .HasColumnType("timestamp with time zone"); b.HasKey("Id"); diff --git a/EmployeeManagmentDataModels/EmployeeManagmentDataModels.csproj b/EmployeeManagmentDataModels/EmployeeManagmentDataModels.csproj index fa71b7a..acb35f3 100644 --- a/EmployeeManagmentDataModels/EmployeeManagmentDataModels.csproj +++ b/EmployeeManagmentDataModels/EmployeeManagmentDataModels.csproj @@ -5,5 +5,19 @@ enable enable + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + diff --git a/EmployeeManagmentView/App.xaml b/EmployeeManagmentView/App.xaml index e117ae8..dac89bc 100644 --- a/EmployeeManagmentView/App.xaml +++ b/EmployeeManagmentView/App.xaml @@ -1,8 +1,6 @@  + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> diff --git a/EmployeeManagmentView/App.xaml.cs b/EmployeeManagmentView/App.xaml.cs index 09e2aea..b7ae8b3 100644 --- a/EmployeeManagmentView/App.xaml.cs +++ b/EmployeeManagmentView/App.xaml.cs @@ -5,6 +5,9 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.EntityFrameworkCore; using System; using System.Windows; +using Microsoft.Extensions.Logging; +using EmployeeManagmentContracts.StoragesContracts; +using EmployeeManagmentDataBaseImplement.Implements; namespace EmployeeManagmentView { @@ -29,19 +32,28 @@ namespace EmployeeManagmentView MessageBox.Show(ex.Message, "Ошибка при открытии MainWindow", MessageBoxButton.OK, MessageBoxImage.Error); } + base.OnStartup(e); } private static void ConfigureServices(ServiceCollection services) { - // Регистрация контекста базы данных с использованием конфигурации services.AddLogging(configure => configure.AddConsole()); - // Регистрация бизнес-логики и других сервисов + + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); - // Регистрация окон services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + + } } } diff --git a/EmployeeManagmentView/EmployeeManagmentView.csproj b/EmployeeManagmentView/EmployeeManagmentView.csproj index 02c7a05..0853e4b 100644 --- a/EmployeeManagmentView/EmployeeManagmentView.csproj +++ b/EmployeeManagmentView/EmployeeManagmentView.csproj @@ -9,17 +9,26 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + diff --git a/EmployeeManagmentView/MainWindow.xaml b/EmployeeManagmentView/MainWindow.xaml index 9b3652d..55a6cbf 100644 --- a/EmployeeManagmentView/MainWindow.xaml +++ b/EmployeeManagmentView/MainWindow.xaml @@ -12,11 +12,6 @@ FontSize="24" FontWeight="Bold" Margin="10"/> -