From ca42b880f1f8ed85b79df3c1464b3786a4d43026 Mon Sep 17 00:00:00 2001 From: maksim Date: Tue, 26 Nov 2024 22:35:12 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A2=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=B5=D1=82=20=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D0=B5=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BC?= =?UTF-8?q?=D0=B5=D0=B6=D0=B4=D1=83=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=86=D0=B0=D0=BC=D0=B8=20=D0=B8=20=D0=B4=D0=BE=D0=B1=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=84=D0=B8=D0=B7=D0=B8?= =?UTF-8?q?=D1=87=D0=B5=D1=81=D0=BA=D0=BE=D0=B3=D0=BE=20=D0=BB=D0=B8=D1=86?= =?UTF-8?q?=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogic/PhisicalPersonLogic.cs | 129 ++++++------------ .../BusinessLogic/SalaryLogic.cs | 29 +++- .../BusinessLogic/VacationLogic.cs | 29 +++- .../IPhisicalPersonLogic.cs | 8 +- .../BusinessLogicContracts/ISalaryLogic.cs | 8 +- .../BusinessLogicContracts/IVacationLogic.cs | 8 +- .../ViewModels/PhisicalPersonViewModel.cs | 2 +- .../Implements/PhisicalPersonStorage.cs | 120 +++++++++++++--- ...ner.cs => 20241126175607_Init.Designer.cs} | 22 ++- ...nitMigration.cs => 20241126175607_Init.cs} | 17 +-- ...mployeeManagementDbContextModelSnapshot.cs | 18 +-- .../Models/Employee.cs | 2 +- .../Models/Salary.cs | 2 +- .../Models/Vacation.cs | 2 +- .../Models/IEmployee.cs | 2 +- EmployeeManagmentDataModels/Models/ISalary.cs | 2 +- .../Models/IVacation.cs | 2 +- EmployeeManagmentView/App.xaml | 97 ++++++++++++- EmployeeManagmentView/App.xaml.cs | 6 +- EmployeeManagmentView/EmployeesWindow.xaml | 8 -- EmployeeManagmentView/EmployeesWindow.xaml.cs | 29 ---- EmployeeManagmentView/MainWindow.xaml | 48 +++---- EmployeeManagmentView/MainWindow.xaml.cs | 26 ++-- .../AddPhysicalPersonWindow.xaml | 76 +++++++++++ .../AddPhysicalPersonWindow.xaml.cs | 65 +++++++++ .../PhysicalPersonManagementWindow.xaml | 44 ++++++ .../PhysicalPersonManagementWindow.xaml.cs | 38 ++++++ EmployeeManagmentView/SalariesWindow.xaml | 8 -- EmployeeManagmentView/SalariesWindow.xaml.cs | 27 ---- EmployeeManagmentView/VacationsWindow.xaml | 8 -- EmployeeManagmentView/VacationsWindow.xaml.cs | 27 ---- 31 files changed, 587 insertions(+), 322 deletions(-) rename EmployeeManagmentDataBaseImplement/Migrations/{20241124115213_InitMigration.Designer.cs => 20241126175607_Init.Designer.cs} (90%) rename EmployeeManagmentDataBaseImplement/Migrations/{20241124115213_InitMigration.cs => 20241126175607_Init.cs} (92%) delete mode 100644 EmployeeManagmentView/EmployeesWindow.xaml delete mode 100644 EmployeeManagmentView/EmployeesWindow.xaml.cs create mode 100644 EmployeeManagmentView/PhysicalPerson/AddPhysicalPersonWindow.xaml create mode 100644 EmployeeManagmentView/PhysicalPerson/AddPhysicalPersonWindow.xaml.cs create mode 100644 EmployeeManagmentView/PhysicalPerson/PhysicalPersonManagementWindow.xaml create mode 100644 EmployeeManagmentView/PhysicalPerson/PhysicalPersonManagementWindow.xaml.cs delete mode 100644 EmployeeManagmentView/SalariesWindow.xaml delete mode 100644 EmployeeManagmentView/SalariesWindow.xaml.cs delete mode 100644 EmployeeManagmentView/VacationsWindow.xaml delete mode 100644 EmployeeManagmentView/VacationsWindow.xaml.cs diff --git a/EmployeeManagmentBusinessLogic/BusinessLogic/PhisicalPersonLogic.cs b/EmployeeManagmentBusinessLogic/BusinessLogic/PhisicalPersonLogic.cs index bd92558..8185cef 100644 --- a/EmployeeManagmentBusinessLogic/BusinessLogic/PhisicalPersonLogic.cs +++ b/EmployeeManagmentBusinessLogic/BusinessLogic/PhisicalPersonLogic.cs @@ -9,115 +9,68 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using EmployeeManagmentContracts.StoragesContracts; +using Microsoft.Extensions.Logging; +using EmployeeManagmentDataBaseImplement.Implements; namespace EmployeeManagmentBusinessLogic.BusinessLogic { public class PhisicalPersonLogic : IPhisicalPersonLogic { - private readonly EmployeeManagementDbContext _context; + private readonly ILogger _logger; + private readonly IPhisicalPersonStorage _phisicalPersonStorage; - public PhisicalPersonLogic(EmployeeManagementDbContext context) + public PhisicalPersonLogic(ILogger logger, IPhisicalPersonStorage phisicalPersonStorage) { - _context = context; + _logger = logger; + _phisicalPersonStorage = phisicalPersonStorage; } - public void CreateOrUpdate(PhisicalPersonBindingModel model) + public List GetFullList() { - PhisicalPerson? person = _context.PhysicalPersons - .FirstOrDefault(p => p.Id == model.Id); + return _phisicalPersonStorage.GetFullList(); + } - if (person == null) + public List GetFilteredList(PhisicalPersonSearchModel model) + { + return _phisicalPersonStorage.GetFilteredList(model); + } + + public PhisicalPersonViewModel? GetElement(int id) + { + return _phisicalPersonStorage.GetElement(id); + } + + public void Insert(PhisicalPersonViewModel model) + { + if (string.IsNullOrWhiteSpace(model.Name) || string.IsNullOrWhiteSpace(model.Surname)) { - // Создание нового - person = new PhisicalPerson - { - Name = model.Name, - Surname = model.Surname, - Patronymic = model.Patronomic, - Birthday = model.Birthday, - Gender = model.Gender, - Address = model.Address, - Telephone = model.Telephone - }; - _context.PhysicalPersons.Add(person); - } - else - { - // Обновление существующего - person.Name = model.Name; - person.Surname = model.Surname; - person.Patronymic = model.Patronomic; - person.Birthday = model.Birthday; - person.Gender = model.Gender; - person.Address = model.Address; - person.Telephone = model.Telephone; + throw new ArgumentException("Имя и фамилия обязательны для заполнения."); } - _context.SaveChanges(); + _phisicalPersonStorage.Insert(model); + } + + public void Update(PhisicalPersonViewModel model) + { + var element = _phisicalPersonStorage.GetElement(model.Id); + if (element == null) + { + throw new ArgumentException("Элемент не найден."); + } + + _phisicalPersonStorage.Update(model); } public void Delete(int id) { - var person = _context.PhysicalPersons.FirstOrDefault(p => p.Id == id); - if (person != null) + var element = _phisicalPersonStorage.GetElement(id); + if (element == null) { - _context.PhysicalPersons.Remove(person); - _context.SaveChanges(); - } - } - - public PhisicalPersonViewModel? GetPhisicalPersonById(int id) - { - var person = _context.PhysicalPersons - .Where(p => p.Id == id) - .Select(p => new PhisicalPersonViewModel - { - Id = p.Id, - Name = p.Name, - Surname = p.Surname, - Patronomic = p.Patronymic, - Birthday = p.Birthday, - Gender = p.Gender, - Address = p.Address, - Telephone = p.Telephone - }) - .FirstOrDefault(); - - return person; - } - - public List GetPhisicalPersons(PhisicalPersonSearchModel model) - { - var query = _context.PhysicalPersons.AsQueryable(); - - if (!string.IsNullOrEmpty(model.Name)) - { - query = query.Where(p => p.Name.Contains(model.Name)); + throw new ArgumentException("Элемент не найден."); } - if (!string.IsNullOrEmpty(model.Surname)) - { - query = query.Where(p => p.Surname.Contains(model.Surname)); - } - - if (!string.IsNullOrEmpty(model.Patronomic)) - { - query = query.Where(p => p.Patronymic.Contains(model.Patronomic)); - } - - return query - .Select(p => new PhisicalPersonViewModel - { - Id = p.Id, - Name = p.Name, - Surname = p.Surname, - Patronomic = p.Patronymic, - Birthday = p.Birthday, - Gender = p.Gender, - Address = p.Address, - Telephone = p.Telephone - }) - .ToList(); + _phisicalPersonStorage.Delete(id); } } } diff --git a/EmployeeManagmentBusinessLogic/BusinessLogic/SalaryLogic.cs b/EmployeeManagmentBusinessLogic/BusinessLogic/SalaryLogic.cs index 245c06b..c9d3a3f 100644 --- a/EmployeeManagmentBusinessLogic/BusinessLogic/SalaryLogic.cs +++ b/EmployeeManagmentBusinessLogic/BusinessLogic/SalaryLogic.cs @@ -3,14 +3,20 @@ using EmployeeManagmentContracts.BusinessLogicContracts; using EmployeeManagmentContracts.SearchModels; using EmployeeManagmentContracts.StoragesContracts; using EmployeeManagmentContracts.ViewModels; +using EmployeeManagmentDataBaseImplement.Implements; +using Microsoft.Extensions.Logging; namespace EmployeeManagmentBusinessLogic.BusinessLogic { public class SalaryLogic : ISalaryLogic { - public void CreateOrUpdate(SalaryBindingModel model) + private readonly ILogger _logger; + private readonly ISalaryStorage _salaryStorage; + + public SalaryLogic(ILogger logger, ISalaryStorage salaryStorage) { - throw new NotImplementedException(); + _logger = logger; + _salaryStorage = salaryStorage; } public void Delete(int id) @@ -18,12 +24,27 @@ namespace EmployeeManagmentBusinessLogic.BusinessLogic throw new NotImplementedException(); } - public List GetSalaries(SalarySearchModel model) + public PhisicalPersonViewModel? GetElement(int id) { throw new NotImplementedException(); } - public SalaryViewModel? GetSalaryById(int id) + public List GetFilteredList(PhisicalPersonSearchModel model) + { + throw new NotImplementedException(); + } + + public List GetFullList() + { + throw new NotImplementedException(); + } + + public void Insert(PhisicalPersonViewModel model) + { + throw new NotImplementedException(); + } + + public void Update(PhisicalPersonViewModel model) { throw new NotImplementedException(); } diff --git a/EmployeeManagmentBusinessLogic/BusinessLogic/VacationLogic.cs b/EmployeeManagmentBusinessLogic/BusinessLogic/VacationLogic.cs index 2fc1f7a..589f194 100644 --- a/EmployeeManagmentBusinessLogic/BusinessLogic/VacationLogic.cs +++ b/EmployeeManagmentBusinessLogic/BusinessLogic/VacationLogic.cs @@ -3,14 +3,20 @@ using EmployeeManagmentContracts.BusinessLogicContracts; using EmployeeManagmentContracts.SearchModels; using EmployeeManagmentContracts.StoragesContracts; using EmployeeManagmentContracts.ViewModels; +using EmployeeManagmentDataBaseImplement.Implements; +using Microsoft.Extensions.Logging; namespace EmployeeManagmentBusinessLogic.BusinessLogic { public class VacationLogic : IVacationLogic { - public void CreateOrUpdate(VacationBindingModel model) + private readonly ILogger _logger; + private readonly IVacationStorage _vacationStorage; + + public VacationLogic(ILogger logger, IVacationStorage vacationStorage) { - throw new NotImplementedException(); + _logger = logger; + _vacationStorage = vacationStorage; } public void Delete(int id) @@ -18,12 +24,27 @@ namespace EmployeeManagmentBusinessLogic.BusinessLogic throw new NotImplementedException(); } - public VacationViewModel? GetVacationById(int id) + public PhisicalPersonViewModel? GetElement(int id) { throw new NotImplementedException(); } - public List GetVacations(VacationSearchModel model) + public List GetFilteredList(EmployeeSearchModel model) + { + throw new NotImplementedException(); + } + + public List GetFullList() + { + throw new NotImplementedException(); + } + + public void Insert(PhisicalPersonViewModel model) + { + throw new NotImplementedException(); + } + + public void Update(PhisicalPersonViewModel model) { throw new NotImplementedException(); } diff --git a/EmployeeManagmentContracts/BusinessLogicContracts/IPhisicalPersonLogic.cs b/EmployeeManagmentContracts/BusinessLogicContracts/IPhisicalPersonLogic.cs index 6e723b6..92447da 100644 --- a/EmployeeManagmentContracts/BusinessLogicContracts/IPhisicalPersonLogic.cs +++ b/EmployeeManagmentContracts/BusinessLogicContracts/IPhisicalPersonLogic.cs @@ -11,9 +11,11 @@ namespace EmployeeManagmentContracts.BusinessLogicContracts { public interface IPhisicalPersonLogic { - List GetPhisicalPersons(PhisicalPersonSearchModel model); - PhisicalPersonViewModel? GetPhisicalPersonById(int id); - void CreateOrUpdate(PhisicalPersonBindingModel model); + List GetFullList(); + List GetFilteredList(PhisicalPersonSearchModel model); + PhisicalPersonViewModel? GetElement(int id); + void Insert(PhisicalPersonViewModel model); + void Update(PhisicalPersonViewModel model); void Delete(int id); } } diff --git a/EmployeeManagmentContracts/BusinessLogicContracts/ISalaryLogic.cs b/EmployeeManagmentContracts/BusinessLogicContracts/ISalaryLogic.cs index f43d593..8501144 100644 --- a/EmployeeManagmentContracts/BusinessLogicContracts/ISalaryLogic.cs +++ b/EmployeeManagmentContracts/BusinessLogicContracts/ISalaryLogic.cs @@ -11,9 +11,11 @@ namespace EmployeeManagmentContracts.BusinessLogicContracts { public interface ISalaryLogic { - List GetSalaries(SalarySearchModel model); - SalaryViewModel? GetSalaryById(int id); - void CreateOrUpdate(SalaryBindingModel model); + List GetFullList(); + List GetFilteredList(PhisicalPersonSearchModel model); + PhisicalPersonViewModel? GetElement(int id); + void Insert(PhisicalPersonViewModel model); + void Update(PhisicalPersonViewModel model); void Delete(int id); } diff --git a/EmployeeManagmentContracts/BusinessLogicContracts/IVacationLogic.cs b/EmployeeManagmentContracts/BusinessLogicContracts/IVacationLogic.cs index 0cd9b60..2c2570e 100644 --- a/EmployeeManagmentContracts/BusinessLogicContracts/IVacationLogic.cs +++ b/EmployeeManagmentContracts/BusinessLogicContracts/IVacationLogic.cs @@ -11,9 +11,11 @@ namespace EmployeeManagmentContracts.BusinessLogicContracts { public interface IVacationLogic { - List GetVacations(VacationSearchModel model); - VacationViewModel? GetVacationById(int id); - void CreateOrUpdate(VacationBindingModel model); + List GetFullList(); + List GetFilteredList(EmployeeSearchModel model); + PhisicalPersonViewModel? GetElement(int id); + void Insert(PhisicalPersonViewModel model); + void Update(PhisicalPersonViewModel model); void Delete(int id); } } diff --git a/EmployeeManagmentContracts/ViewModels/PhisicalPersonViewModel.cs b/EmployeeManagmentContracts/ViewModels/PhisicalPersonViewModel.cs index f9f1a09..b5fca96 100644 --- a/EmployeeManagmentContracts/ViewModels/PhisicalPersonViewModel.cs +++ b/EmployeeManagmentContracts/ViewModels/PhisicalPersonViewModel.cs @@ -11,7 +11,7 @@ namespace EmployeeManagmentContracts.ViewModels public int Id { get; set; } public string Name { get; set; } = string.Empty; public string Surname { get; set; } = string.Empty; - public string Patronomic { get; set; } = string.Empty; + public string Patronymic { get; set; } = string.Empty; public DateTime Birthday { get; set; } public string Gender { get; set; } = string.Empty; public string Address { get; set; } = string.Empty; diff --git a/EmployeeManagmentDataBaseImplement/Implements/PhisicalPersonStorage.cs b/EmployeeManagmentDataBaseImplement/Implements/PhisicalPersonStorage.cs index d9b2d4a..1c5f103 100644 --- a/EmployeeManagmentDataBaseImplement/Implements/PhisicalPersonStorage.cs +++ b/EmployeeManagmentDataBaseImplement/Implements/PhisicalPersonStorage.cs @@ -2,6 +2,7 @@ using EmployeeManagmentContracts.SearchModels; using EmployeeManagmentContracts.StoragesContracts; using EmployeeManagmentContracts.ViewModels; +using EmployeeManagmentDataBaseImplement.Models; using System; using System.Collections.Generic; using System.Linq; @@ -12,34 +13,117 @@ namespace EmployeeManagmentDataBaseImplement.Implements { public class PhisicalPersonStorage : IPhisicalPersonStorage { - public void Delete(int id) - { - throw new NotImplementedException(); - } - - public PhisicalPersonViewModel? GetElement(int id) - { - throw new NotImplementedException(); - } - - public List GetFilteredList(PhisicalPersonSearchModel model) - { - throw new NotImplementedException(); - } - + // Метод для получения полного списка public List GetFullList() { - throw new NotImplementedException(); + using var context = new EmployeeManagementDbContext(); + + return context.PhysicalPersons + .Select(p => new PhisicalPersonViewModel + { + Id = p.Id, + Name = p.Name, + Surname = p.Surname, + Patronymic = p.Patronymic, + Birthday = p.Birthday, + Gender = p.Gender, + Address = p.Address, + Telephone = p.Telephone + }).ToList(); } + // Метод для получения отфильтрованного списка + public List GetFilteredList(PhisicalPersonSearchModel model) + { + using var context = new EmployeeManagementDbContext(); + + if (model == null) return new List(); + + return context.PhysicalPersons + .Where(p => p.Surname.Contains(model.Surname ?? string.Empty)) + .Select(p => new PhisicalPersonViewModel + { + Id = p.Id, + Name = p.Name, + Surname = p.Surname, + Patronymic = p.Patronymic, + Birthday = p.Birthday, + Gender = p.Gender, + Address = p.Address, + Telephone = p.Telephone + }).ToList(); + } + + // Метод для получения одного элемента по ID + public PhisicalPersonViewModel? GetElement(int id) + { + using var context = new EmployeeManagementDbContext(); + + var entity = context.PhysicalPersons.FirstOrDefault(p => p.Id == id); + return entity == null ? null : new PhisicalPersonViewModel + { + Id = entity.Id, + Name = entity.Name, + Surname = entity.Surname, + Patronymic = entity.Patronymic, + Birthday = entity.Birthday, + Gender = entity.Gender, + Address = entity.Address, + Telephone = entity.Telephone + }; + } + + // Метод для добавления нового физического лица public void Insert(PhisicalPersonViewModel model) { - throw new NotImplementedException(); + using var context = new EmployeeManagementDbContext(); + + var newPerson = new PhisicalPerson + { + Name = model.Name, + Surname = model.Surname, + Patronymic = model.Patronymic, + Birthday = model.Birthday, + Gender = model.Gender, + Address = model.Address, + Telephone = model.Telephone + }; + + context.PhysicalPersons.Add(newPerson); + context.SaveChanges(); } + // Метод для обновления физического лица public void Update(PhisicalPersonViewModel model) { - throw new NotImplementedException(); + using var context = new EmployeeManagementDbContext(); + + var entity = context.PhysicalPersons.FirstOrDefault(p => p.Id == model.Id); + if (entity != null) + { + entity.Name = model.Name; + entity.Surname = model.Surname; + entity.Patronymic = model.Patronymic; + entity.Birthday = model.Birthday; + entity.Gender = model.Gender; + entity.Address = model.Address; + entity.Telephone = model.Telephone; + + context.SaveChanges(); + } + } + + // Метод для удаления физического лица + public void Delete(int id) + { + using var context = new EmployeeManagementDbContext(); + + var entity = context.PhysicalPersons.FirstOrDefault(p => p.Id == id); + if (entity != null) + { + context.PhysicalPersons.Remove(entity); + context.SaveChanges(); + } } } } diff --git a/EmployeeManagmentDataBaseImplement/Migrations/20241124115213_InitMigration.Designer.cs b/EmployeeManagmentDataBaseImplement/Migrations/20241126175607_Init.Designer.cs similarity index 90% rename from EmployeeManagmentDataBaseImplement/Migrations/20241124115213_InitMigration.Designer.cs rename to EmployeeManagmentDataBaseImplement/Migrations/20241126175607_Init.Designer.cs index dc8bd25..49f1eb5 100644 --- a/EmployeeManagmentDataBaseImplement/Migrations/20241124115213_InitMigration.Designer.cs +++ b/EmployeeManagmentDataBaseImplement/Migrations/20241126175607_Init.Designer.cs @@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace EmployeeManagmentDataBaseImplement.Migrations { [DbContext(typeof(EmployeeManagementDbContext))] - [Migration("20241124115213_InitMigration")] - partial class InitMigration + [Migration("20241126175607_Init")] + partial class Init { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -46,7 +46,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations b.Property("PartTimeJob") .HasColumnType("text"); - b.Property("PhisicalPersonsId") + b.Property("PhisicalPersonsId") .HasColumnType("integer"); b.Property("StartJob") @@ -112,7 +112,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations b.Property("Data") .HasColumnType("timestamp with time zone"); - b.Property("EmployeesId") + b.Property("EmployeesId") .HasColumnType("integer"); b.Property("Passed") @@ -139,7 +139,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - b.Property("EmployeesId") + b.Property("EmployeesId") .HasColumnType("integer"); b.Property("EndData") @@ -162,9 +162,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations { b.HasOne("EmployeeManagmentDataBaseImplement.Models.PhisicalPerson", "PhisicalPerson") .WithMany("Employees") - .HasForeignKey("PhisicalPersonsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("PhisicalPersonsId"); b.Navigation("PhisicalPerson"); }); @@ -173,9 +171,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations { b.HasOne("EmployeeManagmentDataBaseImplement.Models.Employee", "Employee") .WithMany("Salaries") - .HasForeignKey("EmployeesId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("EmployeesId"); b.Navigation("Employee"); }); @@ -184,9 +180,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations { b.HasOne("EmployeeManagmentDataBaseImplement.Models.Employee", "Employee") .WithMany("Vacations") - .HasForeignKey("EmployeesId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("EmployeesId"); b.Navigation("Employee"); }); diff --git a/EmployeeManagmentDataBaseImplement/Migrations/20241124115213_InitMigration.cs b/EmployeeManagmentDataBaseImplement/Migrations/20241126175607_Init.cs similarity index 92% rename from EmployeeManagmentDataBaseImplement/Migrations/20241124115213_InitMigration.cs rename to EmployeeManagmentDataBaseImplement/Migrations/20241126175607_Init.cs index 74efa7b..96c27e0 100644 --- a/EmployeeManagmentDataBaseImplement/Migrations/20241124115213_InitMigration.cs +++ b/EmployeeManagmentDataBaseImplement/Migrations/20241126175607_Init.cs @@ -7,7 +7,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace EmployeeManagmentDataBaseImplement.Migrations { /// - public partial class InitMigration : Migration + public partial class Init : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) @@ -42,7 +42,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations 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) + PhisicalPersonsId = table.Column(type: "integer", nullable: true) }, constraints: table => { @@ -51,8 +51,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations name: "FK_Employees_PhysicalPersons_PhisicalPersonsId", column: x => x.PhisicalPersonsId, principalTable: "PhysicalPersons", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + principalColumn: "Id"); }); migrationBuilder.CreateTable( @@ -66,7 +65,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations 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) + EmployeesId = table.Column(type: "integer", nullable: true) }, constraints: table => { @@ -75,8 +74,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations name: "FK_Salaries_Employees_EmployeesId", column: x => x.EmployeesId, principalTable: "Employees", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + principalColumn: "Id"); }); migrationBuilder.CreateTable( @@ -88,7 +86,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations 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) + EmployeesId = table.Column(type: "integer", nullable: true) }, constraints: table => { @@ -97,8 +95,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations name: "FK_Vacations_Employees_EmployeesId", column: x => x.EmployeesId, principalTable: "Employees", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + principalColumn: "Id"); }); migrationBuilder.CreateIndex( diff --git a/EmployeeManagmentDataBaseImplement/Migrations/EmployeeManagementDbContextModelSnapshot.cs b/EmployeeManagmentDataBaseImplement/Migrations/EmployeeManagementDbContextModelSnapshot.cs index f7d9ffe..7e2ec9b 100644 --- a/EmployeeManagmentDataBaseImplement/Migrations/EmployeeManagementDbContextModelSnapshot.cs +++ b/EmployeeManagmentDataBaseImplement/Migrations/EmployeeManagementDbContextModelSnapshot.cs @@ -43,7 +43,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations b.Property("PartTimeJob") .HasColumnType("text"); - b.Property("PhisicalPersonsId") + b.Property("PhisicalPersonsId") .HasColumnType("integer"); b.Property("StartJob") @@ -109,7 +109,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations b.Property("Data") .HasColumnType("timestamp with time zone"); - b.Property("EmployeesId") + b.Property("EmployeesId") .HasColumnType("integer"); b.Property("Passed") @@ -136,7 +136,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - b.Property("EmployeesId") + b.Property("EmployeesId") .HasColumnType("integer"); b.Property("EndData") @@ -159,9 +159,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations { b.HasOne("EmployeeManagmentDataBaseImplement.Models.PhisicalPerson", "PhisicalPerson") .WithMany("Employees") - .HasForeignKey("PhisicalPersonsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("PhisicalPersonsId"); b.Navigation("PhisicalPerson"); }); @@ -170,9 +168,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations { b.HasOne("EmployeeManagmentDataBaseImplement.Models.Employee", "Employee") .WithMany("Salaries") - .HasForeignKey("EmployeesId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("EmployeesId"); b.Navigation("Employee"); }); @@ -181,9 +177,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations { b.HasOne("EmployeeManagmentDataBaseImplement.Models.Employee", "Employee") .WithMany("Vacations") - .HasForeignKey("EmployeesId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("EmployeesId"); b.Navigation("Employee"); }); diff --git a/EmployeeManagmentDataBaseImplement/Models/Employee.cs b/EmployeeManagmentDataBaseImplement/Models/Employee.cs index 826a117..23429bd 100644 --- a/EmployeeManagmentDataBaseImplement/Models/Employee.cs +++ b/EmployeeManagmentDataBaseImplement/Models/Employee.cs @@ -20,7 +20,7 @@ namespace EmployeeManagmentDataBaseImplement.Models public float Bid { get; set; } [ForeignKey("PhisicalPerson")] - public int PhisicalPersonsId { get; set; } + public int? PhisicalPersonsId { get; set; } public PhisicalPerson? PhisicalPerson { get; set; } public List Salaries { get; set; } = new(); diff --git a/EmployeeManagmentDataBaseImplement/Models/Salary.cs b/EmployeeManagmentDataBaseImplement/Models/Salary.cs index d3c9304..54c90fd 100644 --- a/EmployeeManagmentDataBaseImplement/Models/Salary.cs +++ b/EmployeeManagmentDataBaseImplement/Models/Salary.cs @@ -21,7 +21,7 @@ namespace EmployeeManagmentDataBaseImplement.Models public bool Passed { get; set; } [ForeignKey("Employee")] - public int EmployeesId { get; set; } + public int? EmployeesId { get; set; } public Employee? Employee { get; set; } } } diff --git a/EmployeeManagmentDataBaseImplement/Models/Vacation.cs b/EmployeeManagmentDataBaseImplement/Models/Vacation.cs index bec2b39..0e01422 100644 --- a/EmployeeManagmentDataBaseImplement/Models/Vacation.cs +++ b/EmployeeManagmentDataBaseImplement/Models/Vacation.cs @@ -19,7 +19,7 @@ namespace EmployeeManagmentDataBaseImplement.Models public bool Passed { get; set; } [ForeignKey("Employee")] - public int EmployeesId { get; set; } + public int? EmployeesId { get; set; } public Employee? Employee { get; set; } } } diff --git a/EmployeeManagmentDataModels/Models/IEmployee.cs b/EmployeeManagmentDataModels/Models/IEmployee.cs index f19e68d..c840229 100644 --- a/EmployeeManagmentDataModels/Models/IEmployee.cs +++ b/EmployeeManagmentDataModels/Models/IEmployee.cs @@ -15,6 +15,6 @@ namespace EmployeeManagmentDataModels.Models DateTime? EndJob { get; set; } string? PartTimeJob { get; set; } float Bid { get; set; } - int PhisicalPersonsId { get; set; } + int? PhisicalPersonsId { get; set; } } } diff --git a/EmployeeManagmentDataModels/Models/ISalary.cs b/EmployeeManagmentDataModels/Models/ISalary.cs index 6dcdabc..ba9efd9 100644 --- a/EmployeeManagmentDataModels/Models/ISalary.cs +++ b/EmployeeManagmentDataModels/Models/ISalary.cs @@ -14,6 +14,6 @@ namespace EmployeeManagmentDataModels.Models float? Premium { get; set; } DateTime? Data { get; set; } bool Passed { get; set; } - int EmployeesId { get; set; } + int? EmployeesId { get; set; } } } diff --git a/EmployeeManagmentDataModels/Models/IVacation.cs b/EmployeeManagmentDataModels/Models/IVacation.cs index 4dc0f87..9503a8c 100644 --- a/EmployeeManagmentDataModels/Models/IVacation.cs +++ b/EmployeeManagmentDataModels/Models/IVacation.cs @@ -13,6 +13,6 @@ namespace EmployeeManagmentDataModels.Models DateTime StartData { get; set; } DateTime EndData { get; set; } bool Passed { get; set; } - int EmployeesId { get; set; } + int? EmployeesId { get; set; } } } diff --git a/EmployeeManagmentView/App.xaml b/EmployeeManagmentView/App.xaml index dac89bc..a468742 100644 --- a/EmployeeManagmentView/App.xaml +++ b/EmployeeManagmentView/App.xaml @@ -2,6 +2,101 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> - + + + + + + + + + diff --git a/EmployeeManagmentView/App.xaml.cs b/EmployeeManagmentView/App.xaml.cs index b7ae8b3..68cbf54 100644 --- a/EmployeeManagmentView/App.xaml.cs +++ b/EmployeeManagmentView/App.xaml.cs @@ -47,11 +47,11 @@ namespace EmployeeManagmentView services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); + } diff --git a/EmployeeManagmentView/EmployeesWindow.xaml b/EmployeeManagmentView/EmployeesWindow.xaml deleted file mode 100644 index d7487bb..0000000 --- a/EmployeeManagmentView/EmployeesWindow.xaml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - diff --git a/EmployeeManagmentView/EmployeesWindow.xaml.cs b/EmployeeManagmentView/EmployeesWindow.xaml.cs deleted file mode 100644 index 02752bb..0000000 --- a/EmployeeManagmentView/EmployeesWindow.xaml.cs +++ /dev/null @@ -1,29 +0,0 @@ -using EmployeeManagmentBusinessLogic.BusinessLogic; -using EmployeeManagmentContracts.BusinessLogicContracts; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; - -namespace EmployeeManagmentView -{ - /// - /// Логика взаимодействия для EmployeesWindow.xaml - /// - public partial class EmployeesWindow : Window - { - public EmployeesWindow() - { - InitializeComponent(); - } - } -} diff --git a/EmployeeManagmentView/MainWindow.xaml b/EmployeeManagmentView/MainWindow.xaml index 55a6cbf..587d67f 100644 --- a/EmployeeManagmentView/MainWindow.xaml +++ b/EmployeeManagmentView/MainWindow.xaml @@ -1,32 +1,26 @@  + Title="Отдел кадров УлГТУ" Height="450" Width="800" Background="#0D2D4F"> + + - - -