From 066378286fbbad5d930b5df8d06f4ed276797485 Mon Sep 17 00:00:00 2001 From: K Date: Sun, 21 Apr 2024 20:33:26 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BC=D0=BD=D0=BE=D0=B3=D0=BE=20=D1=87=D0=B5?= =?UTF-8?q?=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BeautySalonBusinessLogic.csproj | 1 - .../BusinessLogic/CosmeticLogic.cs | 120 +++++++++++++ .../BusinessLogic/LaborCostsLogic.cs | 109 ++++++++++++ .../BusinessLogic/ServiceLogic.cs | 119 +++++++++++++ .../BusinessLogic/StaffMemberLogic.cs | 167 ++++++++++++++++++ .../BeautySalonContracts.csproj | 8 - .../BindingModels/CosmeticBindingModel.cs | 19 ++ .../BindingModels/LaborCostsBindingModel.cs | 18 ++ .../BindingModels/ServiceBindingModel.cs | 18 ++ .../BindingModels/StaffMemberBindingModel.cs | 21 +++ .../BusinessLogicContracts/ICosmeticLogic.cs | 16 ++ .../ILaborCostsLogic.cs | 17 ++ .../BusinessLogicContracts/IServiceLogic.cs | 16 ++ .../IStaffMemberLogic.cs | 16 ++ .../SearchModels/CosmeticSearchModel.cs | 16 ++ .../SearchModels/LaborCostsSearchModel.cs | 15 ++ .../SearchModels/ServiceSearchModel.cs | 11 ++ .../SearchModels/StaffMemberSearchModel.cs | 12 ++ .../StoragesContracts/ICosmeticStorage.cs | 22 +++ .../StoragesContracts/ILaborCostsStorage.cs | 21 +++ .../StoragesContracts/IServiceStorage.cs | 21 +++ .../StoragesContracts/IStaffMemberStorage.cs | 21 +++ .../ViewModels/CosmeticViewModel.cs | 26 +++ .../CosmeticWithProceduresViewModel.cs | 8 + .../ViewModels/LaborCostsViewModel.cs | 24 +++ .../ViewModels/ServiceCosmeticViewModel.cs | 16 ++ .../ViewModels/ServiceViewModel.cs | 29 +++ .../ViewModels/StaffMemberViewModel.cs | 36 ++++ .../BeautySalonDataModels.csproj | 5 - .../Enums/OrderStatus.cs | 21 +++ .../Models/ICosmeticModel.cs | 16 ++ .../Models/ILaborCostsModel.cs | 15 ++ .../Models/IServiceModel.cs | 15 ++ .../Models/IStaffMemberModel.cs | 19 ++ .../BeautySalonDatabase.cs | 28 ++- .../BeautySalonDatabaseImplement.csproj | 5 - .../Implements/CosmeticStorage.cs | 124 +++++++++++++ .../Implements/LaborCostsStorage.cs | 106 +++++++++++ .../Implements/ServiceStorage.cs | 133 ++++++++++++++ .../Implements/StaffMemberStorage.cs | 97 ++++++++++ .../Models/Cosmetic.cs | 73 ++++++++ .../Models/LaborCosts.cs | 59 +++++++ .../Models/Service.cs | 105 +++++++++++ .../Models/ServiceCosmetic.cs | 28 +++ .../Models/StaffMember.cs | 87 +++++++++ 45 files changed, 1858 insertions(+), 21 deletions(-) create mode 100644 BeautySalonView/BeautySalonBusinessLogic/BusinessLogic/CosmeticLogic.cs create mode 100644 BeautySalonView/BeautySalonBusinessLogic/BusinessLogic/LaborCostsLogic.cs create mode 100644 BeautySalonView/BeautySalonBusinessLogic/BusinessLogic/ServiceLogic.cs create mode 100644 BeautySalonView/BeautySalonBusinessLogic/BusinessLogic/StaffMemberLogic.cs create mode 100644 BeautySalonView/BeautySalonContracts/BindingModels/CosmeticBindingModel.cs create mode 100644 BeautySalonView/BeautySalonContracts/BindingModels/LaborCostsBindingModel.cs create mode 100644 BeautySalonView/BeautySalonContracts/BindingModels/ServiceBindingModel.cs create mode 100644 BeautySalonView/BeautySalonContracts/BindingModels/StaffMemberBindingModel.cs create mode 100644 BeautySalonView/BeautySalonContracts/BusinessLogicContracts/ICosmeticLogic.cs create mode 100644 BeautySalonView/BeautySalonContracts/BusinessLogicContracts/ILaborCostsLogic.cs create mode 100644 BeautySalonView/BeautySalonContracts/BusinessLogicContracts/IServiceLogic.cs create mode 100644 BeautySalonView/BeautySalonContracts/BusinessLogicContracts/IStaffMemberLogic.cs create mode 100644 BeautySalonView/BeautySalonContracts/SearchModels/CosmeticSearchModel.cs create mode 100644 BeautySalonView/BeautySalonContracts/SearchModels/LaborCostsSearchModel.cs create mode 100644 BeautySalonView/BeautySalonContracts/SearchModels/ServiceSearchModel.cs create mode 100644 BeautySalonView/BeautySalonContracts/SearchModels/StaffMemberSearchModel.cs create mode 100644 BeautySalonView/BeautySalonContracts/StoragesContracts/ICosmeticStorage.cs create mode 100644 BeautySalonView/BeautySalonContracts/StoragesContracts/ILaborCostsStorage.cs create mode 100644 BeautySalonView/BeautySalonContracts/StoragesContracts/IServiceStorage.cs create mode 100644 BeautySalonView/BeautySalonContracts/StoragesContracts/IStaffMemberStorage.cs create mode 100644 BeautySalonView/BeautySalonContracts/ViewModels/CosmeticViewModel.cs create mode 100644 BeautySalonView/BeautySalonContracts/ViewModels/CosmeticWithProceduresViewModel.cs create mode 100644 BeautySalonView/BeautySalonContracts/ViewModels/LaborCostsViewModel.cs create mode 100644 BeautySalonView/BeautySalonContracts/ViewModels/ServiceCosmeticViewModel.cs create mode 100644 BeautySalonView/BeautySalonContracts/ViewModels/ServiceViewModel.cs create mode 100644 BeautySalonView/BeautySalonContracts/ViewModels/StaffMemberViewModel.cs create mode 100644 BeautySalonView/BeautySalonDataModels/Enums/OrderStatus.cs create mode 100644 BeautySalonView/BeautySalonDataModels/Models/ICosmeticModel.cs create mode 100644 BeautySalonView/BeautySalonDataModels/Models/ILaborCostsModel.cs create mode 100644 BeautySalonView/BeautySalonDataModels/Models/IServiceModel.cs create mode 100644 BeautySalonView/BeautySalonDataModels/Models/IStaffMemberModel.cs create mode 100644 BeautySalonView/BeautySalonDatabaseImplement/Implements/CosmeticStorage.cs create mode 100644 BeautySalonView/BeautySalonDatabaseImplement/Implements/LaborCostsStorage.cs create mode 100644 BeautySalonView/BeautySalonDatabaseImplement/Implements/ServiceStorage.cs create mode 100644 BeautySalonView/BeautySalonDatabaseImplement/Implements/StaffMemberStorage.cs create mode 100644 BeautySalonView/BeautySalonDatabaseImplement/Models/Cosmetic.cs create mode 100644 BeautySalonView/BeautySalonDatabaseImplement/Models/LaborCosts.cs create mode 100644 BeautySalonView/BeautySalonDatabaseImplement/Models/Service.cs create mode 100644 BeautySalonView/BeautySalonDatabaseImplement/Models/ServiceCosmetic.cs create mode 100644 BeautySalonView/BeautySalonDatabaseImplement/Models/StaffMember.cs diff --git a/BeautySalonView/BeautySalonBusinessLogic/BeautySalonBusinessLogic.csproj b/BeautySalonView/BeautySalonBusinessLogic/BeautySalonBusinessLogic.csproj index 4cc37a2..d08f0db 100644 --- a/BeautySalonView/BeautySalonBusinessLogic/BeautySalonBusinessLogic.csproj +++ b/BeautySalonView/BeautySalonBusinessLogic/BeautySalonBusinessLogic.csproj @@ -19,7 +19,6 @@ - diff --git a/BeautySalonView/BeautySalonBusinessLogic/BusinessLogic/CosmeticLogic.cs b/BeautySalonView/BeautySalonBusinessLogic/BusinessLogic/CosmeticLogic.cs new file mode 100644 index 0000000..10da427 --- /dev/null +++ b/BeautySalonView/BeautySalonBusinessLogic/BusinessLogic/CosmeticLogic.cs @@ -0,0 +1,120 @@ +using BeautySalonContracts.BindingModels; +using BeautySalonContracts.BusinessLogicContracts; +using BeautySalonContracts.SearchModels; +using BeautySalonContracts.StoragesContracts; +using BeautySalonContracts.ViewModels; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautySalonBusinessLogic.BusinessLogics +{ + public class CosmeticLogic : ICosmeticLogic + { + private readonly ILogger _logger; + private readonly ICosmeticStorage _cosmeticStorage; + public CosmeticLogic(ILogger logger, ICosmeticStorage cosmeticStorage) + { + _logger = logger; + _cosmeticStorage = cosmeticStorage; + } + public List? ReadList(CosmeticSearchModel? model) + { + _logger.LogInformation("ReadList. CosmeticName: {CosmeticName}. Id: {Id}", + model?.CosmeticName, model?.Id); + var list = model == null ? _cosmeticStorage.GetFullList() : + _cosmeticStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count: {Count}", list.Count); + return list; + } + public CosmeticViewModel? ReadElement(CosmeticSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. CosmeticName: {CosmeticName}. Id: {Id}", + model.CosmeticName, model.Id); + var element = _cosmeticStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + _logger.LogInformation("ReadElement find. Id: {Id}", element.Id); + return element; + } + public bool Create(CosmeticBindingModel model) + { + CheckModel(model); + if (_cosmeticStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(CosmeticBindingModel model) + { + CheckModel(model); + if (_cosmeticStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(CosmeticBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id: {Id}", model.Id); + if (_cosmeticStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(CosmeticBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.CosmeticName)) + { + throw new ArgumentNullException("Нет названия косметики", nameof(model.CosmeticName)); + } + if (string.IsNullOrEmpty(model.Brand)) + { + throw new ArgumentNullException("Не указан бренд косметики", nameof(model.CosmeticName)); + } + if (model.CosmeticPrice <= 0) + { + throw new ArgumentNullException("Цена косметики должна быть больше 0", nameof(model.CosmeticPrice)); + } + _logger.LogInformation("Cosmetic. Brand: {Brand}. CosmeticName: {CosmeticName}. CosmeticPrice: {CosmeticPrice}. Id: {Id}", + model.Brand, model.CosmeticName, model.CosmeticPrice, model.Id); + var element = _cosmeticStorage.GetElement(new CosmeticSearchModel + { + CosmeticName = model.CosmeticName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Косметика с таким названием уже есть"); + } + } + } +} diff --git a/BeautySalonView/BeautySalonBusinessLogic/BusinessLogic/LaborCostsLogic.cs b/BeautySalonView/BeautySalonBusinessLogic/BusinessLogic/LaborCostsLogic.cs new file mode 100644 index 0000000..5618a2a --- /dev/null +++ b/BeautySalonView/BeautySalonBusinessLogic/BusinessLogic/LaborCostsLogic.cs @@ -0,0 +1,109 @@ +using BeautySalonContracts.BindingModels; +using BeautySalonContracts.BusinessLogicContracts; +using BeautySalonContracts.SearchModels; +using BeautySalonContracts.StoragesContracts; +using BeautySalonContracts.ViewModels; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautySalonBusinessLogic.BusinessLogics +{ + public class LaborCostsLogic : ILaborCostsLogic + { + private readonly ILogger _logger; + private readonly ILaborCostsStorage _laborCostsStorage; + public LaborCostsLogic(ILogger logger, ILaborCostsStorage laborCostsStorage) + { + _logger = logger; + _laborCostsStorage = laborCostsStorage; + } + + public List? ReadList(LaborCostsSearchModel? model) + { + _logger.LogInformation("ReadList. Id: {Id}", + model?.Id); + var list = model == null ? _laborCostsStorage.GetFullList() : + _laborCostsStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count: {Count}", list.Count); + return list; + } + public LaborCostsViewModel? ReadElement(LaborCostsSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. Id: {Id}", + model.Id); + var element = _laborCostsStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + _logger.LogInformation("ReadElement find. Id: {Id}", element.Id); + return element; + } + public bool Create(LaborCostsBindingModel model) + { + CheckModel(model); + if (_laborCostsStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(LaborCostsBindingModel model) + { + CheckModel(model); + if (_laborCostsStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(LaborCostsBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id: {Id}", model.Id); + if (_laborCostsStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(LaborCostsBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (model.NumberHours <= 0) + { + throw new ArgumentNullException("Количество часов должно быть больше 0", nameof(model.NumberHours)); + } + if (string.IsNullOrEmpty(model.Difficulty)) + { + throw new ArgumentNullException("Не указана сложность трудозатраты", nameof(model.Difficulty)); + } + _logger.LogInformation("LaborCosts. NumberHours: {NumberHours}. Difficulty: {Difficulty}. Id: {Id}", + model.NumberHours, model.Difficulty, model.Id); + } + } +} diff --git a/BeautySalonView/BeautySalonBusinessLogic/BusinessLogic/ServiceLogic.cs b/BeautySalonView/BeautySalonBusinessLogic/BusinessLogic/ServiceLogic.cs new file mode 100644 index 0000000..ff77560 --- /dev/null +++ b/BeautySalonView/BeautySalonBusinessLogic/BusinessLogic/ServiceLogic.cs @@ -0,0 +1,119 @@ +using BeautySalonContracts.BindingModels; +using BeautySalonContracts.BusinessLogicContracts; +using BeautySalonContracts.SearchModels; +using BeautySalonContracts.StoragesContracts; +using BeautySalonContracts.ViewModels; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautySalonBusinessLogic.BusinessLogics +{ + public class ServiceLogic : IServiceLogic + { + private readonly ILogger _logger; + private readonly IServiceStorage _serviceStorage; + public ServiceLogic(ILogger logger, IServiceStorage serviceStorage) + { + _logger = logger; + _serviceStorage = serviceStorage; + } + + public List? ReadList(ServiceSearchModel? model) + { + _logger.LogInformation("ReadList. ServiceName: {ServiceName}. Id: {Id}", + model?.ServiceName, model?.Id); + var list = model == null ? _serviceStorage.GetFullList() : + _serviceStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count: {Count}", list.Count); + return list; + } + public ServiceViewModel? ReadElement(ServiceSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. ServiceName: {ServiceName}. Id: {Id}", + model.ServiceName, model.Id); + var element = _serviceStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + _logger.LogInformation("ReadElement find. Id: {Id}", element.Id); + return element; + } + public bool Create(ServiceBindingModel model) + { + CheckModel(model); + if (_serviceStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(ServiceBindingModel model) + { + CheckModel(model); + if (_serviceStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(ServiceBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id: {Id}", model.Id); + if (_serviceStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(ServiceBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.ServiceName)) + { + throw new ArgumentNullException("Нет названия услуги", nameof(model.ServiceName)); + } + + if (model.ServicePrice <= 0) + { + throw new ArgumentNullException("Цена услуги должна быть больше 0", + nameof(model.ServicePrice)); + } + _logger.LogInformation("Service. ServiceName: {ServiceName}. Cost: {Cost}. Id: {Id}", + model.ServiceName, model.ServicePrice, model.Id); + var element = _serviceStorage.GetElement(new ServiceSearchModel + { + ServiceName = model.ServiceName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Услуга с таким названием уже есть"); + } + } + } +} diff --git a/BeautySalonView/BeautySalonBusinessLogic/BusinessLogic/StaffMemberLogic.cs b/BeautySalonView/BeautySalonBusinessLogic/BusinessLogic/StaffMemberLogic.cs new file mode 100644 index 0000000..bf22ed1 --- /dev/null +++ b/BeautySalonView/BeautySalonBusinessLogic/BusinessLogic/StaffMemberLogic.cs @@ -0,0 +1,167 @@ +using BeautySalonContracts.BindingModels; +using BeautySalonContracts.BusinessLogicContracts; +using BeautySalonContracts.SearchModels; +using BeautySalonContracts.StoragesContracts; +using BeautySalonContracts.ViewModels; +using Microsoft.Extensions.Logging; + +namespace BeautySalonBusinessLogic.BusinessLogics +{ + public class StaffMemberLogic : IStaffMemberLogic + { + private readonly int _passwordMaxLength = 25; + private readonly int _passwordMinLength = 6; + + private readonly ILogger _logger; + private readonly IStaffMemberStorage _staffMemberStorage; + public StaffMemberLogic(ILogger logger, IStaffMemberStorage staffMemberStorage) + { + _logger = logger; + _staffMemberStorage = staffMemberStorage; + } + public bool Create(StaffMemberBindingModel model) + { + CheckModel(model); + + if (_staffMemberStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + + return false; + } + + return true; + } + + public bool Delete(StaffMemberBindingModel model) + { + CheckModel(model, false); + + _logger.LogInformation("Delete. Id: {Id}", model.Id); + + if (_staffMemberStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + + return false; + } + + return true; + } + + public StaffMemberViewModel? ReadElement(StaffMemberSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + _logger.LogInformation("ReadElement. StaffMemberLogin: {StaffMemberLogin}. StaffMemberEmail: {StaffMemberEmail} Id: {Id}", + model.StaffMemberLogin, model.StaffMemberEmail, model.Id); + + var element = _staffMemberStorage.GetElement(model); + + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + + _logger.LogInformation("ReadElement find. Id: {Id}", element.Id); + + return element; + } + + public List? ReadList(StaffMemberSearchModel? model) + { + _logger.LogInformation("ReadElement. StaffMemberLogin: {StaffMemberLogin}. StaffMemberEmail: {StaffMemberEmail} Id: {Id}", + model?.StaffMemberLogin, model?.StaffMemberEmail, model?.Id); + + var list = model == null ? _staffMemberStorage.GetFullList() : _staffMemberStorage.GetFilteredList(model); + + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + + _logger.LogInformation("ReadList. Count: {Count}", list.Count); + + return list; + } + + public bool Update(StaffMemberBindingModel model) + { + CheckModel(model); + + if (_staffMemberStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + private void CheckModel(StaffMemberBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.StaffMemberName)) + { + throw new ArgumentNullException("Нет имени сотрудника", nameof(model.StaffMemberLogin)); + } + if (string.IsNullOrEmpty(model.StaffMemberSurname)) + { + throw new ArgumentNullException("Нет фамилии сотрудника", nameof(model.StaffMemberLogin)); + } + if (string.IsNullOrEmpty(model.StaffMemberSpecialty)) + { + throw new ArgumentNullException("Нет специальности сотрудника", nameof(model.StaffMemberLogin)); + } + if (string.IsNullOrEmpty(model.StaffMemberLogin)) + { + throw new ArgumentNullException("Нет логина сотрудника", nameof(model.StaffMemberLogin)); + } + if (string.IsNullOrEmpty(model.StaffMemberEmail)) + { + throw new ArgumentNullException("Нет почты сотрудника", nameof(model.StaffMemberEmail)); + } + if (string.IsNullOrEmpty(model.StaffMemberPassword)) + { + throw new ArgumentNullException("Нет пароля сотрудника", nameof(model.StaffMemberPassword)); + } + if (string.IsNullOrEmpty(model.StaffMemberPhone)) + { + throw new ArgumentNullException("Нет телефона сотрудника", nameof(model.StaffMemberEmail)); + } + + if (model.StaffMemberPassword.Length < _passwordMinLength) + { + throw new ArgumentNullException("Пароль слишком короткий", nameof(model.StaffMemberPassword)); + } + + if (model.StaffMemberPassword.Length > _passwordMaxLength) + { + throw new ArgumentNullException("Пароль слишком длинный", nameof(model.StaffMemberPassword)); + } + _logger.LogInformation("ReadElement. StaffMemberLogin: {StaffMemberLogin}. StaffMemberEmail: {StaffMemberEmail} Id: {Id}", + model.StaffMemberLogin, model.StaffMemberEmail, model.Id); + + var element = _staffMemberStorage.GetElement(new StaffMemberSearchModel + { + StaffMemberEmail = model.StaffMemberEmail + }); + + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Сотрудник с такой почтой уже есть"); + } + } + } +} diff --git a/BeautySalonView/BeautySalonContracts/BeautySalonContracts.csproj b/BeautySalonView/BeautySalonContracts/BeautySalonContracts.csproj index 6d5d754..9c9950d 100644 --- a/BeautySalonView/BeautySalonContracts/BeautySalonContracts.csproj +++ b/BeautySalonView/BeautySalonContracts/BeautySalonContracts.csproj @@ -10,12 +10,4 @@ - - - - - - - - diff --git a/BeautySalonView/BeautySalonContracts/BindingModels/CosmeticBindingModel.cs b/BeautySalonView/BeautySalonContracts/BindingModels/CosmeticBindingModel.cs new file mode 100644 index 0000000..ae4d2fa --- /dev/null +++ b/BeautySalonView/BeautySalonContracts/BindingModels/CosmeticBindingModel.cs @@ -0,0 +1,19 @@ +using BeautySalonDataModels; +using BeautySalonDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautySalonContracts.BindingModels +{ + public class CosmeticBindingModel : ICosmeticModel + { + public int Id { get; set; } + public string CosmeticName { get; set; } = string.Empty; + public string Brand { get; set; } = string.Empty; + public double CosmeticPrice { get; set; } + public int LaborCostId { get; set; } + } +} diff --git a/BeautySalonView/BeautySalonContracts/BindingModels/LaborCostsBindingModel.cs b/BeautySalonView/BeautySalonContracts/BindingModels/LaborCostsBindingModel.cs new file mode 100644 index 0000000..8837ec8 --- /dev/null +++ b/BeautySalonView/BeautySalonContracts/BindingModels/LaborCostsBindingModel.cs @@ -0,0 +1,18 @@ +using BeautySalonDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautySalonContracts.BindingModels +{ + public class LaborCostsBindingModel : ILaborCostsModel + { + public int Id { get; set; } + public int NumberHours { get; set; } + public string Difficulty { get; set; } = string.Empty; + public int StaffMemberId { get; set; } + + } +} diff --git a/BeautySalonView/BeautySalonContracts/BindingModels/ServiceBindingModel.cs b/BeautySalonView/BeautySalonContracts/BindingModels/ServiceBindingModel.cs new file mode 100644 index 0000000..519640e --- /dev/null +++ b/BeautySalonView/BeautySalonContracts/BindingModels/ServiceBindingModel.cs @@ -0,0 +1,18 @@ +using BeautySalonDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautySalonContracts.BindingModels +{ + public class ServiceBindingModel : IServiceModel + { + public int Id { get; set; } + public string ServiceName { get; set; } = string.Empty; + public double ServicePrice { get; set; } + public int StaffMemberId { get; set; } + public Dictionary ServiceCosmetics { get; set; } = new(); + } +} diff --git a/BeautySalonView/BeautySalonContracts/BindingModels/StaffMemberBindingModel.cs b/BeautySalonView/BeautySalonContracts/BindingModels/StaffMemberBindingModel.cs new file mode 100644 index 0000000..4f3e0c5 --- /dev/null +++ b/BeautySalonView/BeautySalonContracts/BindingModels/StaffMemberBindingModel.cs @@ -0,0 +1,21 @@ +using BeautySalonDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautySalonContracts.BindingModels +{ + public class StaffMemberBindingModel : IStaffMemberModel + { + public int Id { get; set; } + public string StaffMemberName { get; set; } = string.Empty; + public string StaffMemberSurname { get; set; } = string.Empty; + public string StaffMemberSpecialty { get; set; } = string.Empty; + public string StaffMemberLogin { get; set; } = string.Empty; + public string StaffMemberEmail { get; set; } = string.Empty; + public string StaffMemberPassword { get; set; } = string.Empty; + public string StaffMemberPhone { get; set; } = string.Empty; + } +} diff --git a/BeautySalonView/BeautySalonContracts/BusinessLogicContracts/ICosmeticLogic.cs b/BeautySalonView/BeautySalonContracts/BusinessLogicContracts/ICosmeticLogic.cs new file mode 100644 index 0000000..dcd3016 --- /dev/null +++ b/BeautySalonView/BeautySalonContracts/BusinessLogicContracts/ICosmeticLogic.cs @@ -0,0 +1,16 @@ +using System.Collections.Generic; +using BeautySalonContracts.BindingModels; +using BeautySalonContracts.ViewModels; +using BeautySalonContracts.SearchModels; + +namespace BeautySalonContracts.BusinessLogicContracts +{ + public interface ICosmeticLogic + { + List? ReadList(CosmeticSearchModel? model); + CosmeticViewModel? ReadElement(CosmeticSearchModel model); + bool Create(CosmeticBindingModel model); + bool Update(CosmeticBindingModel model); + bool Delete(CosmeticBindingModel model); + } +} diff --git a/BeautySalonView/BeautySalonContracts/BusinessLogicContracts/ILaborCostsLogic.cs b/BeautySalonView/BeautySalonContracts/BusinessLogicContracts/ILaborCostsLogic.cs new file mode 100644 index 0000000..8f51d38 --- /dev/null +++ b/BeautySalonView/BeautySalonContracts/BusinessLogicContracts/ILaborCostsLogic.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; +using BeautySalonContracts.BindingModels; +using BeautySalonContracts.ViewModels; +using BeautySalonContracts.SearchModels; + +namespace BeautySalonContracts.BusinessLogicContracts +{ + public interface ILaborCostsLogic + { + List? ReadList(LaborCostsSearchModel? model); + LaborCostsViewModel? ReadElement(LaborCostsSearchModel model); + bool Create(LaborCostsBindingModel model); + bool Update(LaborCostsBindingModel model); + bool Delete(LaborCostsBindingModel model); + + } +} diff --git a/BeautySalonView/BeautySalonContracts/BusinessLogicContracts/IServiceLogic.cs b/BeautySalonView/BeautySalonContracts/BusinessLogicContracts/IServiceLogic.cs new file mode 100644 index 0000000..dc871f1 --- /dev/null +++ b/BeautySalonView/BeautySalonContracts/BusinessLogicContracts/IServiceLogic.cs @@ -0,0 +1,16 @@ +using System.Collections.Generic; +using BeautySalonContracts.BindingModels; +using BeautySalonContracts.ViewModels; +using BeautySalonContracts.SearchModels; + +namespace BeautySalonContracts.BusinessLogicContracts +{ + public interface IServiceLogic + { + List? ReadList(ServiceSearchModel? model); + ServiceViewModel? ReadElement(ServiceSearchModel model); + bool Create(ServiceBindingModel model); + bool Update(ServiceBindingModel model); + bool Delete(ServiceBindingModel model); + } +} diff --git a/BeautySalonView/BeautySalonContracts/BusinessLogicContracts/IStaffMemberLogic.cs b/BeautySalonView/BeautySalonContracts/BusinessLogicContracts/IStaffMemberLogic.cs new file mode 100644 index 0000000..45df5a9 --- /dev/null +++ b/BeautySalonView/BeautySalonContracts/BusinessLogicContracts/IStaffMemberLogic.cs @@ -0,0 +1,16 @@ +using System.Collections.Generic; +using BeautySalonContracts.BindingModels; +using BeautySalonContracts.ViewModels; +using BeautySalonContracts.SearchModels; + +namespace BeautySalonContracts.BusinessLogicContracts +{ + public interface IStaffMemberLogic + { + List? ReadList(StaffMemberSearchModel? model); + StaffMemberViewModel? ReadElement(StaffMemberSearchModel model); + bool Create(StaffMemberBindingModel model); + bool Update(StaffMemberBindingModel model); + bool Delete(StaffMemberBindingModel model); + } +} diff --git a/BeautySalonView/BeautySalonContracts/SearchModels/CosmeticSearchModel.cs b/BeautySalonView/BeautySalonContracts/SearchModels/CosmeticSearchModel.cs new file mode 100644 index 0000000..4d7ca1e --- /dev/null +++ b/BeautySalonView/BeautySalonContracts/SearchModels/CosmeticSearchModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautySalonContracts.SearchModels +{ + public class CosmeticSearchModel + { + public int? Id {get; set; } + public string? CosmeticName { get; set; } + public string? Brand { get; set; } + public int? LaborCostId { get; set; } + } +} diff --git a/BeautySalonView/BeautySalonContracts/SearchModels/LaborCostsSearchModel.cs b/BeautySalonView/BeautySalonContracts/SearchModels/LaborCostsSearchModel.cs new file mode 100644 index 0000000..acc11b0 --- /dev/null +++ b/BeautySalonView/BeautySalonContracts/SearchModels/LaborCostsSearchModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautySalonContracts.SearchModels +{ + public class LaborCostsSearchModel + { + public int? Id { get; set; } + public string? Difficulty { get; set; } + public int? StaffMemberId { get; set; } + } +} diff --git a/BeautySalonView/BeautySalonContracts/SearchModels/ServiceSearchModel.cs b/BeautySalonView/BeautySalonContracts/SearchModels/ServiceSearchModel.cs new file mode 100644 index 0000000..a8d2d2a --- /dev/null +++ b/BeautySalonView/BeautySalonContracts/SearchModels/ServiceSearchModel.cs @@ -0,0 +1,11 @@ +using System; + +namespace BeautySalonContracts.SearchModels +{ + public class ServiceSearchModel + { + public int? Id { get; set; } + public string? ServiceName { get; set; } + public int? StaffMemberId { get; set; } + } +} diff --git a/BeautySalonView/BeautySalonContracts/SearchModels/StaffMemberSearchModel.cs b/BeautySalonView/BeautySalonContracts/SearchModels/StaffMemberSearchModel.cs new file mode 100644 index 0000000..ac65fac --- /dev/null +++ b/BeautySalonView/BeautySalonContracts/SearchModels/StaffMemberSearchModel.cs @@ -0,0 +1,12 @@ +namespace BeautySalonContracts.SearchModels +{ + public class StaffMemberSearchModel + { + public int? Id { get; set; } + public string? StaffMemberName { get; set; } + public string? StaffMemberSpecialty { get; set; } + public string? StaffMemberLogin { get; set; } + public string? StaffMemberEmail { get; set; } + public string? StaffMemberPassword { get; set; } + } +} diff --git a/BeautySalonView/BeautySalonContracts/StoragesContracts/ICosmeticStorage.cs b/BeautySalonView/BeautySalonContracts/StoragesContracts/ICosmeticStorage.cs new file mode 100644 index 0000000..42e45a1 --- /dev/null +++ b/BeautySalonView/BeautySalonContracts/StoragesContracts/ICosmeticStorage.cs @@ -0,0 +1,22 @@ +using BeautySalonContracts.BindingModels; +using BeautySalonContracts.SearchModels; +using BeautySalonContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautySalonContracts.StoragesContracts +{ + public interface ICosmeticStorage + { + List GetFullList(); + List GetFilteredList(CosmeticSearchModel model); + CosmeticViewModel? GetElement(CosmeticSearchModel model); + CosmeticViewModel? Insert(CosmeticBindingModel model); + CosmeticViewModel? Update(CosmeticBindingModel model); + CosmeticViewModel? Delete(CosmeticBindingModel model); + List GetCosmeticProcedures(CosmeticSearchModel model); + } +} diff --git a/BeautySalonView/BeautySalonContracts/StoragesContracts/ILaborCostsStorage.cs b/BeautySalonView/BeautySalonContracts/StoragesContracts/ILaborCostsStorage.cs new file mode 100644 index 0000000..75e4647 --- /dev/null +++ b/BeautySalonView/BeautySalonContracts/StoragesContracts/ILaborCostsStorage.cs @@ -0,0 +1,21 @@ +using BeautySalonContracts.BindingModels; +using BeautySalonContracts.SearchModels; +using BeautySalonContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautySalonContracts.StoragesContracts +{ + public interface ILaborCostsStorage + { + List GetFullList(); + List GetFilteredList(LaborCostsSearchModel model); + LaborCostsViewModel? GetElement(LaborCostsSearchModel model); + LaborCostsViewModel? Insert(LaborCostsBindingModel model); + LaborCostsViewModel? Update(LaborCostsBindingModel model); + LaborCostsViewModel? Delete(LaborCostsBindingModel model); + } +} diff --git a/BeautySalonView/BeautySalonContracts/StoragesContracts/IServiceStorage.cs b/BeautySalonView/BeautySalonContracts/StoragesContracts/IServiceStorage.cs new file mode 100644 index 0000000..1538b09 --- /dev/null +++ b/BeautySalonView/BeautySalonContracts/StoragesContracts/IServiceStorage.cs @@ -0,0 +1,21 @@ +using BeautySalonContracts.BindingModels; +using BeautySalonContracts.SearchModels; +using BeautySalonContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautySalonContracts.StoragesContracts +{ + public interface IServiceStorage + { + List GetFullList(); + List GetFilteredList(ServiceSearchModel model); + ServiceViewModel? GetElement(ServiceSearchModel model); + ServiceViewModel? Insert(ServiceBindingModel model); + ServiceViewModel? Update(ServiceBindingModel model); + ServiceViewModel? Delete(ServiceBindingModel model); + } +} diff --git a/BeautySalonView/BeautySalonContracts/StoragesContracts/IStaffMemberStorage.cs b/BeautySalonView/BeautySalonContracts/StoragesContracts/IStaffMemberStorage.cs new file mode 100644 index 0000000..4139699 --- /dev/null +++ b/BeautySalonView/BeautySalonContracts/StoragesContracts/IStaffMemberStorage.cs @@ -0,0 +1,21 @@ +using BeautySalonContracts.BindingModels; +using BeautySalonContracts.SearchModels; +using BeautySalonContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautySalonContracts.StoragesContracts +{ + public interface IStaffMemberStorage + { + List GetFullList(); + List GetFilteredList(StaffMemberSearchModel model); + StaffMemberViewModel? GetElement(StaffMemberSearchModel model); + StaffMemberViewModel? Insert(StaffMemberBindingModel model); + StaffMemberViewModel? Update(StaffMemberBindingModel model); + StaffMemberViewModel? Delete(StaffMemberBindingModel model); + } +} diff --git a/BeautySalonView/BeautySalonContracts/ViewModels/CosmeticViewModel.cs b/BeautySalonView/BeautySalonContracts/ViewModels/CosmeticViewModel.cs new file mode 100644 index 0000000..cf12435 --- /dev/null +++ b/BeautySalonView/BeautySalonContracts/ViewModels/CosmeticViewModel.cs @@ -0,0 +1,26 @@ +using BeautySalonDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautySalonContracts.ViewModels +{ + public class CosmeticViewModel : ICosmeticModel + { + public int Id { get; set; } + + [DisplayName("Наименование косметики")] + public string CosmeticName { get; set; } = string.Empty; + + [DisplayName("Бренд косметики")] + public string Brand { get; set; } = string.Empty; + + [DisplayName("Цена косметики")] + public double CosmeticPrice { get; set; } + + public int LaborCostId { get; set; } + } +} diff --git a/BeautySalonView/BeautySalonContracts/ViewModels/CosmeticWithProceduresViewModel.cs b/BeautySalonView/BeautySalonContracts/ViewModels/CosmeticWithProceduresViewModel.cs new file mode 100644 index 0000000..ef1fa46 --- /dev/null +++ b/BeautySalonView/BeautySalonContracts/ViewModels/CosmeticWithProceduresViewModel.cs @@ -0,0 +1,8 @@ +namespace BeautySalonContracts.ViewModels +{ + public class CosmeticWithProceduresViewModel + { + public CosmeticViewModel Cosmetic { get; set; } = new(); + public List Procedures { get; set; } = new(); + } +} diff --git a/BeautySalonView/BeautySalonContracts/ViewModels/LaborCostsViewModel.cs b/BeautySalonView/BeautySalonContracts/ViewModels/LaborCostsViewModel.cs new file mode 100644 index 0000000..3fe2a9a --- /dev/null +++ b/BeautySalonView/BeautySalonContracts/ViewModels/LaborCostsViewModel.cs @@ -0,0 +1,24 @@ +using BeautySalonDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautySalonContracts.ViewModels +{ + public class LaborCostsViewModel : ILaborCostsModel + { + public int Id { get; set; } + + [DisplayName("Количество часов")] + public int NumberHours { get; set; } + + [DisplayName("Сложность")] + public string Difficulty{ get; set; } = string.Empty; + public int StaffMemberId { get; set; } + + + } +} diff --git a/BeautySalonView/BeautySalonContracts/ViewModels/ServiceCosmeticViewModel.cs b/BeautySalonView/BeautySalonContracts/ViewModels/ServiceCosmeticViewModel.cs new file mode 100644 index 0000000..595d3dd --- /dev/null +++ b/BeautySalonView/BeautySalonContracts/ViewModels/ServiceCosmeticViewModel.cs @@ -0,0 +1,16 @@ +namespace BeautySalonContracts.ViewModels +{ + public class ServiceCosmeticViewModel + { + public CosmeticViewModel Cosmetic { get; set; } = null!; + public int Count { get; set; } + + public ServiceCosmeticViewModel() { } + + public ServiceCosmeticViewModel(CosmeticViewModel cosmetic, int count) + { + Cosmetic = cosmetic; + Count = count; + } + } +} \ No newline at end of file diff --git a/BeautySalonView/BeautySalonContracts/ViewModels/ServiceViewModel.cs b/BeautySalonView/BeautySalonContracts/ViewModels/ServiceViewModel.cs new file mode 100644 index 0000000..4a9f5e8 --- /dev/null +++ b/BeautySalonView/BeautySalonContracts/ViewModels/ServiceViewModel.cs @@ -0,0 +1,29 @@ +using BeautySalonDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautySalonContracts.ViewModels +{ + public class ServiceViewModel : IServiceModel + { + public int Id { get; set; } + + [DisplayName("Наименование услуги")] + public string ServiceName { get; set; } = string.Empty; + + [DisplayName("Цена услуги")] + public double ServicePrice { get; set; } + + public int StaffMemberId { get; set; } + + [DisplayName("Сотрудник")] + public string StaffMemberName { get; set; } = string.Empty; + + public List ServiceCosmetics { get; set; } = new(); + + } +} diff --git a/BeautySalonView/BeautySalonContracts/ViewModels/StaffMemberViewModel.cs b/BeautySalonView/BeautySalonContracts/ViewModels/StaffMemberViewModel.cs new file mode 100644 index 0000000..1eedbd5 --- /dev/null +++ b/BeautySalonView/BeautySalonContracts/ViewModels/StaffMemberViewModel.cs @@ -0,0 +1,36 @@ +using BeautySalonDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautySalonContracts.ViewModels +{ + public class StaffMemberViewModel : IStaffMemberModel + { + public int Id { get; set; } + + [DisplayName("Имя сотрудника")] + public string StaffMemberName { get; set; } = string.Empty; + + [DisplayName("Фамилия сотрудника")] + public string StaffMemberSurname { get; set; } = string.Empty; + + [DisplayName("Специальность сотрудника")] + public string StaffMemberSpecialty{ get; set; } = string.Empty; + + [DisplayName("Логин сотрудника")] + public string StaffMemberLogin { get; set; } = string.Empty; + + [DisplayName("Почта сотрудника")] + public string StaffMemberEmail { get; set; } = string.Empty; + + [DisplayName("Пароль сотрудника")] + public string StaffMemberPassword { get; set; } = string.Empty; + + [DisplayName("Телефон сотрудника")] + public string StaffMemberPhone { get; set; } = string.Empty; + } +} diff --git a/BeautySalonView/BeautySalonDataModels/BeautySalonDataModels.csproj b/BeautySalonView/BeautySalonDataModels/BeautySalonDataModels.csproj index 7264f69..132c02c 100644 --- a/BeautySalonView/BeautySalonDataModels/BeautySalonDataModels.csproj +++ b/BeautySalonView/BeautySalonDataModels/BeautySalonDataModels.csproj @@ -6,9 +6,4 @@ enable - - - - - diff --git a/BeautySalonView/BeautySalonDataModels/Enums/OrderStatus.cs b/BeautySalonView/BeautySalonDataModels/Enums/OrderStatus.cs new file mode 100644 index 0000000..5e7d11e --- /dev/null +++ b/BeautySalonView/BeautySalonDataModels/Enums/OrderStatus.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautySalonDataModels.Enums +{ + public enum OrderStatus + { + Неизвестен = -1, + + Принят = 0, + + Выполняется = 1, + + Готов = 2, + + Выдан = 3 + } +} diff --git a/BeautySalonView/BeautySalonDataModels/Models/ICosmeticModel.cs b/BeautySalonView/BeautySalonDataModels/Models/ICosmeticModel.cs new file mode 100644 index 0000000..4feac78 --- /dev/null +++ b/BeautySalonView/BeautySalonDataModels/Models/ICosmeticModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautySalonDataModels.Models +{ + public interface ICosmeticModel : IId + { + string CosmeticName { get; } + string Brand { get; } + double CosmeticPrice { get; } + int LaborCostId { get; } + } +} diff --git a/BeautySalonView/BeautySalonDataModels/Models/ILaborCostsModel.cs b/BeautySalonView/BeautySalonDataModels/Models/ILaborCostsModel.cs new file mode 100644 index 0000000..b7beb5f --- /dev/null +++ b/BeautySalonView/BeautySalonDataModels/Models/ILaborCostsModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautySalonDataModels.Models +{ + public interface ILaborCostsModel : IId + { + int NumberHours { get; } + string Difficulty { get; } + int StaffMemberId { get; } + } +} diff --git a/BeautySalonView/BeautySalonDataModels/Models/IServiceModel.cs b/BeautySalonView/BeautySalonDataModels/Models/IServiceModel.cs new file mode 100644 index 0000000..506a782 --- /dev/null +++ b/BeautySalonView/BeautySalonDataModels/Models/IServiceModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautySalonDataModels.Models +{ + public interface IServiceModel : IId + { + string ServiceName { get; } + double ServicePrice { get; } + int StaffMemberId { get; } + } +} diff --git a/BeautySalonView/BeautySalonDataModels/Models/IStaffMemberModel.cs b/BeautySalonView/BeautySalonDataModels/Models/IStaffMemberModel.cs new file mode 100644 index 0000000..06203c7 --- /dev/null +++ b/BeautySalonView/BeautySalonDataModels/Models/IStaffMemberModel.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautySalonDataModels.Models +{ + public interface IStaffMemberModel : IId + { + string StaffMemberName { get; } + string StaffMemberSurname { get; } + string StaffMemberSpecialty { get; } + string StaffMemberLogin { get; } + string StaffMemberEmail { get; } + string StaffMemberPassword { get; } + string StaffMemberPhone { get; } + } +} diff --git a/BeautySalonView/BeautySalonDatabaseImplement/BeautySalonDatabase.cs b/BeautySalonView/BeautySalonDatabaseImplement/BeautySalonDatabase.cs index 0a8287b..07f4923 100644 --- a/BeautySalonView/BeautySalonDatabaseImplement/BeautySalonDatabase.cs +++ b/BeautySalonView/BeautySalonDatabaseImplement/BeautySalonDatabase.cs @@ -1,7 +1,31 @@ -namespace BeautySalonDatabaseImplement +using DocumentFormat.OpenXml.Drawing.Charts; +using Microsoft.EntityFrameworkCore; +using BeautySalonDatabaseImplement.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautySalonDatabaseImplement { - public class BeautySalonDatabase + public class BeautySalonDataBase : DbContext { + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + if (optionsBuilder.IsConfigured == false) + { + optionsBuilder.UseSqlServer(@"Data Source=PRETTYNAME;Initial Catalog=BeautySalonDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); + } + base.OnConfiguring(optionsBuilder); + } + public virtual DbSet LaborCosts { set; get; } + public virtual DbSet Cosmetics { set; get; } + public virtual DbSet Services { set; get; } + public virtual DbSet ServiceCosmetics { set; get; } + public virtual DbSet StaffMembers { set; get; } } } diff --git a/BeautySalonView/BeautySalonDatabaseImplement/BeautySalonDatabaseImplement.csproj b/BeautySalonView/BeautySalonDatabaseImplement/BeautySalonDatabaseImplement.csproj index 30953fc..fb300cb 100644 --- a/BeautySalonView/BeautySalonDatabaseImplement/BeautySalonDatabaseImplement.csproj +++ b/BeautySalonView/BeautySalonDatabaseImplement/BeautySalonDatabaseImplement.csproj @@ -21,9 +21,4 @@ - - - - - diff --git a/BeautySalonView/BeautySalonDatabaseImplement/Implements/CosmeticStorage.cs b/BeautySalonView/BeautySalonDatabaseImplement/Implements/CosmeticStorage.cs new file mode 100644 index 0000000..ae8798f --- /dev/null +++ b/BeautySalonView/BeautySalonDatabaseImplement/Implements/CosmeticStorage.cs @@ -0,0 +1,124 @@ +using BeautySalonContracts.BindingModels; +using BeautySalonContracts.SearchModels; +using BeautySalonContracts.StoragesContracts; +using BeautySalonContracts.ViewModels; +using BeautySalonDatabaseImplement.Models; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; + +namespace BeautySalonDatabaseImplement.Implements +{ + public class CosmeticStorage : ICosmeticStorage + { + public List GetFullList() + { + using var context = new BeautySalonDatabase(); + return context.Cosmetics + .Select(x => x.GetViewModel) + .ToList(); + } + public int GetNumberOfPages(int userId, int pageSize) + { + using var context = new BeautySalonDatabase(); + int carsCount = context.LaborsCosts.Where(c => c.LaborCostsId == userId).Count(); + int numberOfpages = (int)Math.Ceiling((double)carsCount / pageSize); + return numberOfpages != 0 ? numberOfpages : 1; + } + + public List GetFilteredList(CosmeticSearchModel model) + { + using var context = new BeautySalonDatabase(); + if (model.Id.HasValue) + { + return context.Cosmetics + .Where(x => x.Id == model.Id) + .Select(x => x.GetViewModel) + .ToList(); + } + if (model.LaborCostsId.HasValue && model.PageNumber.HasValue && model.PageSize.HasValue) + { + return context.Cosmetics + .Where(x => x.LaborCostsId == model.LaborCostsId) + .Skip(model.PageSize.Value * (model.PageNumber.Value - 1)) + .Take(model.PageSize.Value) + .Select(x => x.GetViewModel) + .ToList(); + } + if (model.LaborCostsId.HasValue) + { + return context.Cosmetics + .Where(x => x.LaborCostsId == model.LaborCostsId) + .Select(x => x.GetViewModel) + .ToList(); + } + return new(); + } + + public CosmeticViewModel? GetElement(CosmeticSearchModel model) + { + if (string.IsNullOrEmpty(model.CosmeticName) && !model.Id.HasValue) + { + return null; + } + using var context = new BeautySalonDatabase(); + return context.Cosmetics + .FirstOrDefault(x => (!string.IsNullOrEmpty(model.CosmeticName) && x.CosmeticName == model.CosmeticName) || + (model.Id.HasValue && x.Id == model.Id)) + ?.GetViewModel; + } + + public CosmeticViewModel? Insert(CosmeticBindingModel model) + { + var newCosmetic = Cosmetic.Create(model); + if (newCosmetic == null) + { + return null; + } + using var context = new BeautySalonDatabase(); + context.Cosmetics.Add(newCosmetic); + context.SaveChanges(); + return newCosmetic.GetViewModel; + } + + public CosmeticViewModel? Update(CosmeticBindingModel model) + { + using var context = new BeautySalonDatabase(); + var сosmetic = context.Cosmetics.FirstOrDefault(x => x.Id == model.Id); + if (сosmetic == null) + { + return null; + } + сosmetic.Update(model); + context.SaveChanges(); + return сosmetic.GetViewModel; + } + + public CosmeticViewModel? Delete(CosmeticBindingModel model) + { + using var context = new BeautySalonDatabase(); + var element = context.Cosmetics.FirstOrDefault(rec => rec.Id == model.Id); + if (element != null) + { + context.Cosmetics.Remove(element); + context.SaveChanges(); + return element.GetViewModel; + } + return null; + } + + public List GetCosmeticProcedures(CosmeticSearchModel model) + { + if (model == null) + { + return new(); + } + using var context = new BeautySalonDatabase(); + var procedures = context.ProcedureCosmetics + .Where(x => x.CosmeticId == model.Id) + .Select(x => x.Procedure.GetViewModel) + .ToList(); + return procedures; + } + } +} diff --git a/BeautySalonView/BeautySalonDatabaseImplement/Implements/LaborCostsStorage.cs b/BeautySalonView/BeautySalonDatabaseImplement/Implements/LaborCostsStorage.cs new file mode 100644 index 0000000..8d03240 --- /dev/null +++ b/BeautySalonView/BeautySalonDatabaseImplement/Implements/LaborCostsStorage.cs @@ -0,0 +1,106 @@ +using BeautySalonContracts.BindingModels; +using BeautySalonContracts.SearchModels; +using BeautySalonContracts.StoragesContracts; +using BeautySalonContracts.ViewModels; +using BeautySalonDatabaseImplement.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautySalonDatabaseImplement.Implements +{ + public class LaborCostsStorage : ILaborCostsStorage + { + public LaborCostsViewModel? Delete(LaborCostsBindingModel model) + { + using var context = new BeautySalonDatabase(); + var element = context.LaborsCosts.FirstOrDefault(rec => rec.Id == model.Id); + if (element != null) + { + context.LaborsCosts.Remove(element); + context.SaveChanges(); + return element.GetViewModel; + } + return null; + } + + public LaborCostsViewModel? GetElement(LaborCostsSearchModel model) + { + if (!model.Id.HasValue) + { + return null; + } + using var context = new BeautySalonDatabase(); + return context.LaborsCosts + .FirstOrDefault(x => x.Id == model.Id) + ?.GetViewModel; + } + + public int GetNumberOfPages(int userId, int pageSize) + { + using var context = new BeautySalonDatabase(); + int carsCount = context.LaborsCosts.Where(c => c.LaborCostsId == userId).Count(); + int numberOfpages = (int)Math.Ceiling((double)carsCount / pageSize); + return numberOfpages != 0 ? numberOfpages : 1; + } + + public List GetFilteredList(LaborCostsSearchModel model) + { + using var context = new BeautySalonDatabase(); + if (model.Id.HasValue) + { + return context.LaborsCosts + .Where(x => x.Id == model.Id) + .Select(x => x.GetViewModel) + .ToList(); + } + if (model.LaborCostsId.HasValue && model.PageNumber.HasValue && model.PageSize.HasValue) + { + return context.LaborsCosts + .Where(x => x.LaborCostsId == model.LaborCostsId) + .Skip(model.PageSize.Value * (model.PageNumber.Value - 1)) + .Take(model.PageSize.Value) + .Select(x => x.GetViewModel) + .ToList(); + } + return new(); + } + + public List GetFullList() + { + using var context = new BeautySalonDatabase(); + return context.LaborsCosts + .Select(x => x.GetViewModel) + .ToList(); + } + + public LaborCostsViewModel? Insert(LaborCostsBindingModel model) + { + var newLaborCosts = LaborCosts.Create(model); + if (newLaborCosts == null) + { + return null; + } + using var context = new BeautySalonDatabase(); + context.LaborsCosts.Add(newLaborCosts); + context.SaveChanges(); + return newLaborCosts.GetViewModel; + } + + public LaborCostsViewModel? Update(LaborCostsBindingModel model) + { + using var context = new BeautySalonDatabase(); + var laborCosts = context.LaborsCosts.FirstOrDefault(x => x.Id == model.Id); + if (laborCosts == null) + { + return null; + } + laborCosts.Update(model); + context.SaveChanges(); + return laborCosts.GetViewModel; + } + } +} diff --git a/BeautySalonView/BeautySalonDatabaseImplement/Implements/ServiceStorage.cs b/BeautySalonView/BeautySalonDatabaseImplement/Implements/ServiceStorage.cs new file mode 100644 index 0000000..3f0eb8a --- /dev/null +++ b/BeautySalonView/BeautySalonDatabaseImplement/Implements/ServiceStorage.cs @@ -0,0 +1,133 @@ +using BeautySalonContracts.BindingModels; +using BeautySalonContracts.SearchModels; +using BeautySalonContracts.StoragesContracts; +using BeautySalonContracts.ViewModels; +using BeautySalonDatabaseImplement.Models; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautySalonDatabaseImplement.Implements +{ + public class ServiceStorage : IServiceStorage + { + public ServiceViewModel? Delete(ServiceBindingModel model) + { + using var context = new BeautySalonDatabase(); + var element = context.Services + .Include(x => x.Cosmetics) + .Include(x => x.Orders) + .FirstOrDefault(rec => rec.Id == model.Id); + if (element != null) + { + context.Services.Remove(element); + context.SaveChanges(); + return element.GetViewModel; + } + return null; + } + + public ServiceViewModel? GetElement(ServiceSearchModel model) + { + if (string.IsNullOrEmpty(model.ServiceName) && !model.Id.HasValue) + { + return null; + } + using var context = new BeautySalonDatabase(); + return context.Services + .Include(x => x.Cosmetics) + .ThenInclude(x => x.Cosmetic) + .FirstOrDefault(x => (!string.IsNullOrEmpty(model.ServiceName) && x.ServiceName == model.ServiceName) || + (model.Id.HasValue && x.Id == model.Id)) + ?.GetViewModel; + } + + public int GetNumberOfPages(int userId, int pageSize) + { + using var context = new BeautySalonDatabase(); + int carsCount = context.Services.Where(c => c.LaborCostsId == userId).Count(); + int numberOfpages = (int)Math.Ceiling((double)carsCount / pageSize); + return numberOfpages != 0 ? numberOfpages : 1; + } + + public List GetFilteredList(ServiceSearchModel model) + { + if (model == null) + { + return new(); + } + using var context = new BeautySalonDatabase(); + if (model.LaborCostsId.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue) + { + return context.Services + .Include(x => x.Cosmetics) + .ThenInclude(x => x.Cosmetic) + .Where(x => x.LaborCostsId == model.LaborCostsId && + x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo) + .ToList() + .Select(x => x.GetViewModel) + .ToList(); + } + if (model.LaborCostsId.HasValue && model.PageNumber.HasValue && model.PageSize.HasValue) + { + return context.Services + .Where(x => x.LaborCostsId == model.LaborCostsId) + .Skip(model.PageSize.Value * (model.PageNumber.Value - 1)) + .Take(model.PageSize.Value) + .Select(x => x.GetViewModel) + .ToList(); + } + return new(); + } + + public List GetFullList() + { + using var context = new BeautySalonDatabase(); + return context.Services + .Include(x => x.Cosmetics) + .ThenInclude(x => x.Cosmetic) + .Select(x => x.GetViewModel) + .ToList(); + } + + public ServiceViewModel? Insert(ServiceBindingModel model) + { + using var context = new BeautySalonDatabase(); + var newService = Service.Create(context, model); + if (newService == null) + { + return null; + } + context.Services.Add(newService); + context.SaveChanges(); + return newService.GetViewModel; + } + + public ServiceViewModel? Update(ServiceBindingModel model) + { + using var context = new BeautySalonDatabase(); + using var transaction = context.Database.BeginTransaction(); + try + { + var service = context.Services.FirstOrDefault(rec => rec.Id == model.Id); + if (service == null) + { + return null; + } + service.Update(model); + context.SaveChanges(); + service.UpdateCosmetics(context, model); + transaction.Commit(); + return service.GetViewModel; + } + catch + { + transaction.Rollback(); + throw; + } + } + } +} diff --git a/BeautySalonView/BeautySalonDatabaseImplement/Implements/StaffMemberStorage.cs b/BeautySalonView/BeautySalonDatabaseImplement/Implements/StaffMemberStorage.cs new file mode 100644 index 0000000..72a4d3d --- /dev/null +++ b/BeautySalonView/BeautySalonDatabaseImplement/Implements/StaffMemberStorage.cs @@ -0,0 +1,97 @@ +using BeautySalonContracts.BindingModels; +using BeautySalonContracts.SearchModels; +using BeautySalonContracts.StoragesContracts; +using BeautySalonContracts.ViewModels; +using BeautySalonDatabaseImplement.Models; +using Microsoft.EntityFrameworkCore; +using System.Collections.Generic; +using System.Linq; + +namespace BeautySalonDatabaseImplement.Implements +{ + public class LaborCostsStorage : ILaborCostsStorage + { + public LaborCostsViewModel? Delete(LaborCostsBindingModel model) + { + using var context = new BeautySalonDatabase(); + + var element = context.LaborCostss.FirstOrDefault(rec => rec.Id == model.Id); + + if (element != null) + { + context.LaborCostss.Remove(element); + context.SaveChanges(); + + return element.GetViewModel; + } + + return null; + } + + public LaborCostsViewModel? GetElement(LaborCostsSearchModel model) + { + using var context = new BeautySalonDatabase(); + if (model.Id.HasValue) + return context.LaborCostss + .FirstOrDefault(x => x.Id == model.Id)? + .GetViewModel; + + if (!string.IsNullOrEmpty(model.LaborCostsPassword) && + !string.IsNullOrEmpty(model.LaborCostsLogin)) + return context.LaborCostss + .FirstOrDefault(x => + x.LaborCostsPassword.Equals(model.LaborCostsPassword) && + x.LaborCostsLogin.Equals(model.LaborCostsLogin))? + .GetViewModel; + + return null; + } + + public List GetFilteredList(LaborCostsSearchModel model) + { + throw new NotImplementedException(); + } + + public List GetFullList() + { + using var context = new BeautySalonDatabase(); + return context.LaborCostss + .Select(x => x.GetViewModel) + .ToList(); + } + + public LaborCostsViewModel? Insert(LaborCostsBindingModel model) + { + using var context = new BeautySalonDatabase(); + + var newLaborCosts = LaborCosts.Create(model); + + if (newLaborCosts == null) + { + return null; + } + + context.LaborCostss.Add(newLaborCosts); + context.SaveChanges(); + + return newLaborCosts.GetViewModel; + } + + public LaborCostsViewModel? Update(LaborCostsBindingModel model) + { + using var context = new BeautySalonDatabase(); + + var LaborCosts = context.LaborCostss.FirstOrDefault(x => x.Id == model.Id); + + if (LaborCosts == null) + { + return null; + } + + LaborCosts.Update(model); + context.SaveChanges(); + + return LaborCosts.GetViewModel; + } + } +} diff --git a/BeautySalonView/BeautySalonDatabaseImplement/Models/Cosmetic.cs b/BeautySalonView/BeautySalonDatabaseImplement/Models/Cosmetic.cs new file mode 100644 index 0000000..801c368 --- /dev/null +++ b/BeautySalonView/BeautySalonDatabaseImplement/Models/Cosmetic.cs @@ -0,0 +1,73 @@ +using BeautySalonContracts.BindingModels; +using BeautySalonContracts.ViewModels; +using BeautySalonDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautySalonDatabaseImplement.Models +{ + public class Cosmetic : ICosmeticModel + { + public int Id { get; set; } + [Required] + public string Brand { get; set; } = string.Empty; + + [Required] + public string CosmeticName { get; set; } = string.Empty; + + [Required] + public double CosmeticPrice { get; set; } + + public int LaborCostId { get; set; } + public virtual LaborCosts LaborCost { get; set; } + + //[ForeignKey("CosmeticId")] + //public virtual List Procedures { get; set; } = new(); + + [ForeignKey("CosmeticId")] + public virtual List Services { get; set; } = new(); + + public static Cosmetic Create(CosmeticBindingModel model) + { + + if (model == null) + { + return null; + } + return new Cosmetic() + { + Id = model.Id, + Brand = model.Brand, + CosmeticName = model.CosmeticName, + CosmeticPrice = model.CosmeticPrice, + LaborCostId = model.LaborCostId + }; + } + + public void Update(CosmeticBindingModel model) + { + if (model == null) + { + return; + } + Brand = model.Brand; + CosmeticName = model.CosmeticName; + CosmeticPrice = model.CosmeticPrice; + LaborCostId = model.LaborCostId; + } + + public CosmeticViewModel GetViewModel => new() + { + Id = Id, + Brand = Brand, + CosmeticName = CosmeticName, + CosmeticPrice = CosmeticPrice, + LaborCostId = LaborCostId + }; + } +} diff --git a/BeautySalonView/BeautySalonDatabaseImplement/Models/LaborCosts.cs b/BeautySalonView/BeautySalonDatabaseImplement/Models/LaborCosts.cs new file mode 100644 index 0000000..0b187c6 --- /dev/null +++ b/BeautySalonView/BeautySalonDatabaseImplement/Models/LaborCosts.cs @@ -0,0 +1,59 @@ +using BeautySalonContracts.BindingModels; +using BeautySalonContracts.ViewModels; +using BeautySalonDataModels.Models; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace BeautySalonDatabaseImplement.Models +{ + public class LaborCosts : ILaborCostsModel + { + public int Id { get; set; } + + [Required] + public int NumberHours { get; set; } + + [Required] + public string Difficulty { get; set; } = string.Empty; + + public int StaffMemberId { get; set; } + + public virtual StaffMember StaffMember { get; set; } + + + // Связь трудозатрат и услуг один-ко-многим сущностью Cosmetic + public virtual List Cosmetics { get; set; } = new(); + + public static LaborCosts? Create(LaborCostsBindingModel? model) + { + if (model == null) + { + return null; + } + return new LaborCosts() + { + Id = model.Id, + StaffMemberId = model.StaffMemberId, + NumberHours = model.NumberHours, + Difficulty = model.Difficulty + }; + } + + public void Update(LaborCostsBindingModel? model) + { + if (model == null) + { + return; + } + NumberHours = model.NumberHours; + } + + public LaborCostsViewModel GetViewModel => new() + { + Id = Id, + NumberHours = NumberHours + }; + } + +} diff --git a/BeautySalonView/BeautySalonDatabaseImplement/Models/Service.cs b/BeautySalonView/BeautySalonDatabaseImplement/Models/Service.cs new file mode 100644 index 0000000..59b7caa --- /dev/null +++ b/BeautySalonView/BeautySalonDatabaseImplement/Models/Service.cs @@ -0,0 +1,105 @@ +using BeautySalonContracts.BindingModels; +using BeautySalonContracts.ViewModels; +using BeautySalonDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; + +namespace BeautySalonDatabaseImplement.Models +{ + public class Service : IServiceModel + { + public int Id {get; set; } + + [Required] + public string ServiceName { get; set; } = string.Empty; + + [Required] + public double ServicePrice { get; set; } + + + private List? _serviceCosmetics = null; + + [NotMapped] + public List ServiceCosmetics + { + get + { + _serviceCosmetics ??= Cosmetics + .Select(pc => new ServiceCosmeticViewModel(pc.Cosmetic.GetViewModel, pc.ServiceCosmeticCount)) + .ToList(); + return _serviceCosmetics; + } + } + + // связь услуги и косметки многие - ко - многим + [ForeignKey("ServiceId")] + public virtual List Cosmetics { get; set; } = new(); + + // связь услуги и заказов многие - ко - многим + // [ForeignKey("ServiceId")] + //public virtual List Orders { get; set; } = new(); + + public static Service Create(BeautySalonDataBase context, ServiceBindingModel model) + { + return new Service() + { + Id = model.Id, + ServiceName = model.ServiceName, + ServicePrice = model.ServicePrice, + Cosmetics = model.ServiceCosmetics.Select(x => new ServiceCosmetic() + { + Cosmetic = context.Cosmetics.First(y => y.Id == x.Cosmetic.Id), + ServiceCosmeticCount = x.Count + }).ToList(), + DateCreate = model.DateCreate, + LaborCostsId = model.LaborCostsId, + LaborCostsId = model.LaborCostsId + }; + } + + public void Update(ServiceBindingModel model) + { + ServiceName = model.ServiceName; + ServicePrice = model.ServicePrice; + LaborCostsId = model.LaborCostsId; + } + + public ServiceViewModel GetViewModel => new() + { + Id = Id, + ServiceName = ServiceName, + ServicePrice = ServicePrice, + ServiceCosmetics = ServiceCosmetics, + DateCreate = DateCreate, + LaborCostsId = LaborCostsId, + }; + + public void UpdateCosmetics(BeautySalonDatabase context, ServiceBindingModel model) + { + var serviceSosmetics = context.ServiceCosmetics + .Where(x => x.ServiceId == model.Id) + .ToList(); + context.ServiceCosmetics + .RemoveRange(serviceSosmetics); + var service = context.Services.First(x => x.Id == Id); + foreach (var record in model.ServiceCosmetics) + { + context.ServiceCosmetics.Add(new ServiceCosmetic + { + Service = service, + Cosmetic = context.Cosmetics.First(x => x.Id == record.Cosmetic.Id), + ServiceCosmeticCount = record.Count + }); + context.SaveChanges(); + } + _serviceCosmetics = null; + } + } +} diff --git a/BeautySalonView/BeautySalonDatabaseImplement/Models/ServiceCosmetic.cs b/BeautySalonView/BeautySalonDatabaseImplement/Models/ServiceCosmetic.cs new file mode 100644 index 0000000..1293e3a --- /dev/null +++ b/BeautySalonView/BeautySalonDatabaseImplement/Models/ServiceCosmetic.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautySalonDatabaseImplement.Models +{ + public class ServiceCosmetic + { + public int Id { get; set; } + + [Required] + public int CosmeticId { get; set; } + + [Required] + public int ServiceId { get; set; } + + [Required] + public int ServiceCosmeticCount { get; set; } + + public virtual Cosmetic Cosmetic { get; set; } = new(); + + public virtual Service Service { get; set; } = new(); + } +} diff --git a/BeautySalonView/BeautySalonDatabaseImplement/Models/StaffMember.cs b/BeautySalonView/BeautySalonDatabaseImplement/Models/StaffMember.cs new file mode 100644 index 0000000..26a1d73 --- /dev/null +++ b/BeautySalonView/BeautySalonDatabaseImplement/Models/StaffMember.cs @@ -0,0 +1,87 @@ +using BeautySalonContracts.BindingModels; +using BeautySalonContracts.ViewModels; +using BeautySalonDataModels.Models; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace BeautySalonDatabaseImplement.Models +{ + public class StaffMember : IStaffMemberModel + { + public int Id { get; set; } + + [Required] + public string StaffMemberName { get; set; } = string.Empty; + + [Required] + public string StaffMemberSurname { get; set; } = string.Empty; + + [Required] + public string StaffMemberSpecialty { get; set; } = string.Empty; + + [Required] + public string StaffMemberLogin { get; set; } = string.Empty; + + [Required] + public string StaffMemberEmail { get; set; } = string.Empty; + + [Required] + public string StaffMemberPassword { get; set; } = string.Empty; + + [Required] + public string StaffMemberPhone { get; set; } = string.Empty; + + [ForeignKey("StaffMemberId")] + public virtual List LaborsCosts { get; set; } = new(); + + [ForeignKey("StaffMemberId")] + public virtual List Services { get; set; } = new(); + + public static StaffMember? Create(StaffMemberBindingModel model) + { + + if (model == null) + { + return null; + } + return new StaffMember() + { + Id = model.Id, + StaffMemberName = model.StaffMemberName, + StaffMemberSurname = model.StaffMemberSurname, + StaffMemberSpecialty = model.StaffMemberSpecialty, + StaffMemberLogin = model.StaffMemberLogin, + StaffMemberEmail = model.StaffMemberEmail, + StaffMemberPassword = model.StaffMemberPassword, + StaffMemberPhone = model.StaffMemberPhone, + }; + } + + public void Update(StaffMemberBindingModel model) + { + if (model == null) + { + return; + } + StaffMemberName = model.StaffMemberName; + StaffMemberSurname = model.StaffMemberSurname; + StaffMemberSpecialty = model.StaffMemberSpecialty; + StaffMemberLogin = model.StaffMemberLogin; + StaffMemberEmail = model.StaffMemberEmail; + StaffMemberPassword = model.StaffMemberPassword; + StaffMemberPhone = model.StaffMemberPhone; + } + + public StaffMemberViewModel GetViewModel => new() + { + Id = Id, + StaffMemberName = StaffMemberName, + StaffMemberSurname = StaffMemberSurname, + StaffMemberSpecialty = StaffMemberSpecialty, + StaffMemberLogin = StaffMemberLogin, + StaffMemberEmail = StaffMemberEmail, + StaffMemberPassword = StaffMemberPassword, + StaffMemberPhone = StaffMemberPhone, + }; + } +}