diff --git a/BeautyStudio/BeautyStudio.sln b/BeautyStudio/BeautyStudio.sln index e5fe648..bb0e766 100644 --- a/BeautyStudio/BeautyStudio.sln +++ b/BeautyStudio/BeautyStudio.sln @@ -13,10 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeautyStudioBusinessLogic", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeautyStudioDatabaseImplement", "BeautyStudioDatabaseImplement\BeautyStudioDatabaseImplement.csproj", "{8BEBC76F-F7B5-46CB-A42B-28E133452D52}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeautyStudioRestAPI", "BeautyStudioRestAPI\BeautyStudioRestAPI.csproj", "{50B724DE-086C-4931-8718-AF16E14ED5B0}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClientWebApp", "ClientWebApp\ClientWebApp.csproj", "{970D4EF3-BDAA-483F-9A37-E2CBED2865A2}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -43,14 +39,6 @@ Global {8BEBC76F-F7B5-46CB-A42B-28E133452D52}.Debug|Any CPU.Build.0 = Debug|Any CPU {8BEBC76F-F7B5-46CB-A42B-28E133452D52}.Release|Any CPU.ActiveCfg = Release|Any CPU {8BEBC76F-F7B5-46CB-A42B-28E133452D52}.Release|Any CPU.Build.0 = Release|Any CPU - {50B724DE-086C-4931-8718-AF16E14ED5B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {50B724DE-086C-4931-8718-AF16E14ED5B0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {50B724DE-086C-4931-8718-AF16E14ED5B0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {50B724DE-086C-4931-8718-AF16E14ED5B0}.Release|Any CPU.Build.0 = Release|Any CPU - {970D4EF3-BDAA-483F-9A37-E2CBED2865A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {970D4EF3-BDAA-483F-9A37-E2CBED2865A2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {970D4EF3-BDAA-483F-9A37-E2CBED2865A2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {970D4EF3-BDAA-483F-9A37-E2CBED2865A2}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/BeautyStudio/BeautyStudioBusinessLogic/BeautyStudioBusinessLogic.csproj b/BeautyStudio/BeautyStudioBusinessLogic/BeautyStudioBusinessLogic.csproj index 80e0a5b..3ef7d76 100644 --- a/BeautyStudio/BeautyStudioBusinessLogic/BeautyStudioBusinessLogic.csproj +++ b/BeautyStudio/BeautyStudioBusinessLogic/BeautyStudioBusinessLogic.csproj @@ -10,6 +10,7 @@ + diff --git a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/ClientLogic.cs b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/ClientLogic.cs deleted file mode 100644 index 97d4ef0..0000000 --- a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/ClientLogic.cs +++ /dev/null @@ -1,155 +0,0 @@ -using BeautyStudioContracts.BindingModels; -using BeautyStudioContracts.BusinessLogicContracts; -using BeautyStudioContracts.SearchModels; -using BeautyStudioContracts.StoragesContracts; -using BeautyStudioContracts.ViewModels; -using Microsoft.Extensions.Logging; - -namespace BeautyStudioBusinessLogic.BusinessLogic -{ - public class ClientLogic : IClientLogic - { - private readonly int _passwordMaxLength = 50; - private readonly int _passwordMinLength = 10; - - private readonly ILogger _logger; - private readonly IClientStorage _clientStorage; - public ClientLogic(ILogger logger, IClientStorage clientStorage) - { - _logger = logger; - _clientStorage = clientStorage; - } - public bool Create(ClientBindingModel model) - { - CheckModel(model); - - if (_clientStorage.Insert(model) == null) - { - _logger.LogWarning("Insert operation failed"); - - return false; - } - - return true; - } - - public bool Delete(ClientBindingModel model) - { - CheckModel(model, false); - - _logger.LogInformation("Delete. Id: {Id}", model.Id); - - if (_clientStorage.Delete(model) == null) - { - _logger.LogWarning("Delete operation failed"); - - return false; - } - - return true; - } - - public ClientViewModel? ReadElement(ClientSearchModel model) - { - if (model == null) - { - throw new ArgumentNullException(nameof(model)); - } - - _logger.LogInformation("ReadElement. ClientLogin: {ClientLogin}. ClientFIO: {ClientFIO} ClientEmail: {ClientEmail} Id: {Id}", - model.ClientFIO, model.ClientLogin, model.ClientEmail, model.Id); - - var element = _clientStorage.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(ClientSearchModel? model) - { - _logger.LogInformation("ReadList. ClientLogin: {ClientLogin}. ClientFIO: {ClientFIO} ClientEmail: {ClientEmail} Id: {Id}", - model?.ClientFIO, model?.ClientLogin, model?.ClientEmail, model?.Id); - - var list = model == null ? _clientStorage.GetFullList() : _clientStorage.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(ClientBindingModel model) - { - CheckModel(model); - - if (_clientStorage.Update(model) == null) - { - _logger.LogWarning("Update operation failed"); - return false; - } - return true; - } - - private void CheckModel(ClientBindingModel model, bool withParams = true) - { - if (model == null) - { - throw new ArgumentNullException(nameof(model)); - } - - if (!withParams) - { - return; - } - if (string.IsNullOrEmpty(model.ClientFIO)) - { - throw new ArgumentNullException("Нет ФИО клиента", nameof(model.ClientFIO)); - } - if (string.IsNullOrEmpty(model.ClientLogin)) - { - throw new ArgumentNullException("Нет логина клиента", nameof(model.ClientLogin)); - } - if (string.IsNullOrEmpty(model.ClientEmail)) - { - throw new ArgumentNullException("Нет почты клиента", nameof(model.ClientEmail)); - } - if (string.IsNullOrEmpty(model.ClientPassword)) - { - throw new ArgumentNullException("Нет пароля", nameof(model.ClientPassword)); - } - if (model.ClientPassword.Length < _passwordMinLength) - { - throw new ArgumentNullException("Пароль слишком короткий", nameof(model.ClientPassword)); - } - if (model.ClientPassword.Length > _passwordMaxLength) - { - throw new ArgumentNullException("Пароль слишком длинный", nameof(model.ClientPassword)); - } - - _logger.LogInformation("Client. ClientFIO: {ClientFIO}. ClientLogin: {ClientLogin} ClientEmail: {ClientEmail} Id: {Id}", - model.ClientFIO, model.ClientLogin, model.ClientEmail, model.Id); - - var element = _clientStorage.GetElement(new ClientSearchModel - { - ClientEmail = model.ClientEmail - }); - - if (element != null && element.Id != model.Id) - { - throw new InvalidOperationException("Клиент с такой почтой уже есть"); - } - } - } -} diff --git a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/CosmeticLogic.cs b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/CosmeticLogic.cs index bfdeba7..d645c62 100644 --- a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/CosmeticLogic.cs +++ b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/CosmeticLogic.cs @@ -102,7 +102,7 @@ namespace BeautyStudioBusinessLogic.BusinessLogic throw new ArgumentNullException("Цена косметики должна быть больше 0", nameof(model.CosmeticPrice)); } _logger.LogInformation("Cosmetic. CosmeticName: {CosmeticName}. CosmeticPrice: {CosmeticPrice}. Id: {Id}", - model.CosmeticName, model.CosmeticPrice, model.Id); + model.CosmeticName, model.CosmeticPrice, model.Id); var element = _cosmeticStorage.GetElement(new CosmeticSearchModel { CosmeticName = model.CosmeticName diff --git a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/LaborCostsLogic.cs b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/LaborCostsLogic.cs index 561e416..2540070 100644 --- a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/LaborCostsLogic.cs +++ b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/LaborCostsLogic.cs @@ -12,11 +12,11 @@ using System.Threading.Tasks; namespace BeautyStudioBusinessLogic.BusinessLogics { - public class LaborCostLogic : ILaborCostLogic + public class LaborCostsLogic : ILaborCostLogic { private readonly ILogger _logger; private readonly ILaborCostStorage _laborCostsStorage; - public LaborCostLogic(ILogger logger, ILaborCostStorage laborCostsStorage) + public LaborCostsLogic(ILogger logger, ILaborCostStorage laborCostsStorage) { _logger = logger; _laborCostsStorage = laborCostsStorage; @@ -98,9 +98,12 @@ namespace BeautyStudioBusinessLogic.BusinessLogics { throw new ArgumentNullException("Количество часов должно быть больше 0", nameof(model.TimeSpent)); } - + if (string.IsNullOrEmpty(model.Difficulty)) + { + throw new ArgumentNullException("Не указана сложность трудозатраты", nameof(model.Difficulty)); + } _logger.LogInformation("LaborCost. TimeSpent: {TimeSpent}. Difficulty: {Difficulty}. Id: {Id}", - model.TimeSpent, model.Id); + model.TimeSpent, model.Difficulty, model.Id); } } } diff --git a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/OrderLogic.cs b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/OrderLogic.cs index 25f9494..e128177 100644 --- a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/OrderLogic.cs +++ b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/OrderLogic.cs @@ -3,6 +3,7 @@ using BeautyStudioContracts.BusinessLogicContracts; using BeautyStudioContracts.SearchModels; using BeautyStudioContracts.StoragesContracts; using BeautyStudioContracts.ViewModels; +using BeautyStudioDataModels.Enums; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; @@ -16,7 +17,7 @@ namespace BeautyStudioBusinessLogic.BusinessLogics { private readonly ILogger _logger; private readonly IOrderStorage _orderStorage; - public OrderLogic(ILogger logger, IOrderStorage orderStorage) + public OrderLogic(ILogger logger, IOrderStorage orderStorage) { _logger = logger; _orderStorage = orderStorage; @@ -40,8 +41,8 @@ namespace BeautyStudioBusinessLogic.BusinessLogics { throw new ArgumentNullException(nameof(model)); } - _logger.LogInformation("ReadElement. DateCreate: {DateCreate}. Id: {Id}", - model.DateCreate, model.Id); + _logger.LogInformation("ReadElement. DateCreate: {DateCreate}. DateComplete: {DateComplete}. Id: {Id}", + model.DateCreate, model.DateComplete, model.Id); var element = _orderStorage.GetElement(model); if (element == null) { @@ -98,5 +99,55 @@ namespace BeautyStudioBusinessLogic.BusinessLogics nameof(model.Sum)); } } + public bool ChangeStatus(OrderBindingModel model, OrderStatus newStatus) + { + var vmodel = _orderStorage.GetElement(new() { Id = model.Id }); + + if (vmodel == null) + { + throw new ArgumentNullException(nameof(model)); + } + + if ((int)vmodel.Status + 1 != (int)newStatus) + { + throw new InvalidOperationException($"Попытка перевести заказ не в следующий статус: " + + $"Текущий статус: {vmodel.Status} \n" + + $"Планируемый статус: {newStatus} \n" + + $"Доступный статус: {(OrderStatus)((int)vmodel.Status + 1)}"); + } + + model.Status = newStatus; + model.DateCreate = vmodel.DateCreate; + + model.ServiceId = vmodel.ServiceId; + model.Sum = vmodel.Sum; + + var result = _orderStorage.Update(model); + + if (result == null) + { + _logger.LogWarning("Update operation failed"); + + return false; + } + return true; + } + + //Перевод заказа в состояние принятого на выполнение + public bool TakeOrderInWork(OrderBindingModel model) + { + return ChangeStatus(model, OrderStatus.Принято); + } + + //Перевод заказа в состояние выполнения заказа + public bool FinishOrder(OrderBindingModel model) + { + return ChangeStatus(model, OrderStatus.Выполняется); + } + //Перевод заказа в состояние выполненности (окончательное завершение) + public bool DeliveryOrder(OrderBindingModel model) + { + return ChangeStatus(model, OrderStatus.Выполнено); + } } } diff --git a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/ProcedureLogic.cs b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/ProcedureLogic.cs index 1b40c15..fe5fdbd 100644 --- a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/ProcedureLogic.cs +++ b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/ProcedureLogic.cs @@ -21,7 +21,7 @@ namespace BeautyStudioBusinessLogic.BusinessLogics _logger = logger; _procedureStorage = procedureStorage; } - + public List? ReadList(ProcedureSearchModel? model) { diff --git a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/ServiceLogic.cs b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/ServiceLogic.cs index 047a5cb..77bd596 100644 --- a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/ServiceLogic.cs +++ b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/ServiceLogic.cs @@ -99,13 +99,13 @@ namespace BeautyStudioBusinessLogic.BusinessLogics throw new ArgumentNullException("Нет названия услуги", nameof(model.ServiceName)); } - if (model.Sum <= 0) + if (model.ServicePrice <= 0) { throw new ArgumentNullException("Цена услуги должна быть больше 0", - nameof(model.Sum)); + nameof(model.ServicePrice)); } _logger.LogInformation("Service. ServiceName: {ServiceName}. Cost: {Cost}. Id: {Id}", - model.ServiceName, model.Sum, model.Id); + model.ServiceName, model.ServicePrice, model.Id); var element = _serviceStorage.GetElement(new ServiceSearchModel { ServiceName = model.ServiceName diff --git a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/StaffLogic.cs b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/StaffLogic.cs deleted file mode 100644 index 19cb982..0000000 --- a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/StaffLogic.cs +++ /dev/null @@ -1,159 +0,0 @@ -using BeautyStudioContracts.BindingModels; -using BeautyStudioContracts.BusinessLogicContracts; -using BeautyStudioContracts.SearchModels; -using BeautyStudioContracts.StoragesContracts; -using BeautyStudioContracts.ViewModels; -using Microsoft.Extensions.Logging; - -namespace BeautyStudioBusinessLogic.BusinessLogics -{ - public class StaffLogic : IStaffLogic - { - private readonly int _passwordMaxLength = 25; - private readonly int _passwordMinLength = 6; - - private readonly ILogger _logger; - private readonly IStaffStorage _staffMemberStorage; - public StaffLogic(ILogger logger, IStaffStorage staffMemberStorage) - { - _logger = logger; - _staffMemberStorage = staffMemberStorage; - } - public bool Create(StaffBindingModel model) - { - CheckModel(model); - - if (_staffMemberStorage.Insert(model) == null) - { - _logger.LogWarning("Insert operation failed"); - - return false; - } - - return true; - } - - public bool Delete(StaffBindingModel 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 StaffViewModel? ReadElement(StaffSearchModel model) - { - if (model == null) - { - throw new ArgumentNullException(nameof(model)); - } - - _logger.LogInformation("ReadElement. StaffLogin: {StaffLogin}. StaffEmail: {StaffEmail} Id: {Id}", - model.StaffLogin, model.StaffEmail, 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(StaffSearchModel? model) - { - _logger.LogInformation("ReadElement. StaffLogin: {StaffLogin}. StaffEmail: {StaffEmail} Id: {Id}", - model?.StaffLogin, model?.StaffEmail, 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(StaffBindingModel model) - { - CheckModel(model); - - if (_staffMemberStorage.Update(model) == null) - { - _logger.LogWarning("Update operation failed"); - return false; - } - return true; - } - private void CheckModel(StaffBindingModel model, bool withParams = true) - { - if (model == null) - { - throw new ArgumentNullException(nameof(model)); - } - - if (!withParams) - { - return; - } - if (string.IsNullOrEmpty(model.StaffFIO)) - { - throw new ArgumentNullException("Нет имени сотрудника", nameof(model.StaffLogin)); - } - if (string.IsNullOrEmpty(model.StaffLogin)) - { - throw new ArgumentNullException("Нет логина сотрудника", nameof(model.StaffLogin)); - } - if (string.IsNullOrEmpty(model.StaffEmail)) - { - throw new ArgumentNullException("Нет почты сотрудника", nameof(model.StaffEmail)); - } - if (string.IsNullOrEmpty(model.StaffPassword)) - { - throw new ArgumentNullException("Нет пароля сотрудника", nameof(model.StaffPassword)); - } - if (string.IsNullOrEmpty(model.StaffPhone)) - { - throw new ArgumentNullException("Нет телефона сотрудника", nameof(model.StaffEmail)); - } - - if (model.StaffPassword.Length < _passwordMinLength) - { - throw new ArgumentNullException("Пароль слишком короткий", nameof(model.StaffPassword)); - } - - if (model.StaffPassword.Length > _passwordMaxLength) - { - throw new ArgumentNullException("Пароль слишком длинный", nameof(model.StaffPassword)); - } - _logger.LogInformation("ReadElement. StaffLogin: {StaffLogin}. StaffEmail: {StaffEmail} Id: {Id}", - model.StaffLogin, model.StaffEmail, model.Id); - - var element = _staffMemberStorage.GetElement(new StaffSearchModel - { - StaffEmail = model.StaffEmail - }); - - if (element != null && element.Id != model.Id) - { - throw new InvalidOperationException("Сотрудник с такой почтой уже есть"); - } - } - } -} diff --git a/BeautyStudio/BeautyStudioContracts/BeautyStudioContracts.csproj b/BeautyStudio/BeautyStudioContracts/BeautyStudioContracts.csproj index fd2cf36..f3178d3 100644 --- a/BeautyStudio/BeautyStudioContracts/BeautyStudioContracts.csproj +++ b/BeautyStudio/BeautyStudioContracts/BeautyStudioContracts.csproj @@ -6,6 +6,10 @@ enable + + + + diff --git a/BeautyStudio/BeautyStudioContracts/BindingModels/ClientBindingModel.cs b/BeautyStudio/BeautyStudioContracts/BindingModels/ClientBindingModel.cs deleted file mode 100644 index c4a7d6a..0000000 --- a/BeautyStudio/BeautyStudioContracts/BindingModels/ClientBindingModel.cs +++ /dev/null @@ -1,19 +0,0 @@ -using BeautyStudioDataModels.Models; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BeautyStudioContracts.BindingModels -{ - public class ClientBindingModel : IClientModel - { - public int Id { get; set; } - public string ClientFIO { get; set; } = string.Empty; - public string ClientEmail { get; set; } = string.Empty; - public string ClientPhone { get; set; } = string.Empty; - public string ClientLogin { get; set; } = string.Empty; - public string ClientPassword { get; set; } = string.Empty; - } -} diff --git a/BeautyStudio/BeautyStudioContracts/BindingModels/CosmeticBindingModel.cs b/BeautyStudio/BeautyStudioContracts/BindingModels/CosmeticBindingModel.cs index 3d304ce..80e171e 100644 --- a/BeautyStudio/BeautyStudioContracts/BindingModels/CosmeticBindingModel.cs +++ b/BeautyStudio/BeautyStudioContracts/BindingModels/CosmeticBindingModel.cs @@ -1,4 +1,5 @@ -using BeautyStudioDataModels.Models; +using BeautyStudioContracts.ViewModels; +using BeautyStudioDataModels.Models; using System; using System.Collections.Generic; using System.Linq; @@ -12,7 +13,10 @@ namespace BeautyStudioContracts.BindingModels public int Id { get; set; } public string CosmeticName { get; set; } = string.Empty; public double CosmeticPrice { get; set; } - public int StoreKeeperId { get; set; } public int LaborCostId { get; set; } + + public List ServiceCosmetic { get; set; } = new(); + public List ServiceProcedure { get; set; } = new(); + public List OrderService { get; set; } = new(); } } diff --git a/BeautyStudio/BeautyStudioContracts/BindingModels/LaborCostBindingModel.cs b/BeautyStudio/BeautyStudioContracts/BindingModels/LaborCostBindingModel.cs index 3a10c51..2fefdeb 100644 --- a/BeautyStudio/BeautyStudioContracts/BindingModels/LaborCostBindingModel.cs +++ b/BeautyStudio/BeautyStudioContracts/BindingModels/LaborCostBindingModel.cs @@ -10,7 +10,10 @@ namespace BeautyStudioContracts.BindingModels public class LaborCostBindingModel : ILaborCostModel { public int Id { get ; set; } + public int TimeSpent { get; set; } - public int StaffId { get; set; } + + public string Difficulty { get; set; } = string.Empty; + public int StoreKeeperId { get; set; } } } diff --git a/BeautyStudio/BeautyStudioContracts/BindingModels/OrderBindingModel.cs b/BeautyStudio/BeautyStudioContracts/BindingModels/OrderBindingModel.cs index 69700ea..71be19a 100644 --- a/BeautyStudio/BeautyStudioContracts/BindingModels/OrderBindingModel.cs +++ b/BeautyStudio/BeautyStudioContracts/BindingModels/OrderBindingModel.cs @@ -1,4 +1,5 @@ -using BeautyStudioDataModels.Enums; +using BeautyStudioContracts.ViewModels; +using BeautyStudioDataModels.Enums; using BeautyStudioDataModels.Models; using System; using System.Collections.Generic; @@ -15,8 +16,11 @@ namespace BeautyStudioContracts.BindingModels public DateTime DateCreate { get; set; } = DateTime.Now; public DateTime? DateComplete { get; set; } public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; - public int ClientId { get; set; } public int ServiceId { get; set; } - public int? StaffId { get; set; } + public int CosmeticId { get; set; } + + public List OrderService { get; set; } = new(); + public List OrderCosmetic { get; set; } = new(); + public List OrderProcedure { get; set; } = new(); } } diff --git a/BeautyStudio/BeautyStudioContracts/BindingModels/ProcedureBindingModel.cs b/BeautyStudio/BeautyStudioContracts/BindingModels/ProcedureBindingModel.cs index 0e72a36..e34cdd2 100644 --- a/BeautyStudio/BeautyStudioContracts/BindingModels/ProcedureBindingModel.cs +++ b/BeautyStudio/BeautyStudioContracts/BindingModels/ProcedureBindingModel.cs @@ -14,5 +14,9 @@ namespace BeautyStudioContracts.BindingModels public string ProcedureName { get; set; } = string.Empty; public double ProcedureCost { get; set; } public string ProcedureDescription { get; set; } = string.Empty; + + public List ProcedureCosmetics { get; set; } = new(); + public List ServiceProcedure { get; set; } = new(); + public List OrderProcedure { get; set; } = new(); } } diff --git a/BeautyStudio/BeautyStudioContracts/BindingModels/ServiceBindingModel.cs b/BeautyStudio/BeautyStudioContracts/BindingModels/ServiceBindingModel.cs index b4d05b5..9ed2044 100644 --- a/BeautyStudio/BeautyStudioContracts/BindingModels/ServiceBindingModel.cs +++ b/BeautyStudio/BeautyStudioContracts/BindingModels/ServiceBindingModel.cs @@ -1,4 +1,5 @@ -using BeautyStudioDataModels.Models; +using BeautyStudioContracts.ViewModels; +using BeautyStudioDataModels.Models; using System; using System.Collections.Generic; using System.Linq; @@ -11,7 +12,10 @@ namespace BeautyStudioContracts.BindingModels { public int Id { get; set; } public string ServiceName { get; set; } = string.Empty; - public double Sum { get; set; } - public int StaffId { get; set; } + public double ServicePrice { get; set; } + public int StoreKeeperId { get; set; } + public List ServiceCosmetic { get; set; } = new(); + public List ServiceProcedure { get; set; } = new(); + public List OrderService { get; set; } = new(); } } diff --git a/BeautyStudio/BeautyStudioContracts/BindingModels/StaffBindingModel.cs b/BeautyStudio/BeautyStudioContracts/BindingModels/StaffBindingModel.cs deleted file mode 100644 index 26d2722..0000000 --- a/BeautyStudio/BeautyStudioContracts/BindingModels/StaffBindingModel.cs +++ /dev/null @@ -1,19 +0,0 @@ -using BeautyStudioDataModels.Models; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BeautyStudioContracts.BindingModels -{ - public class StaffBindingModel : IStaffModel - { - public int Id { get; set; } - public string StaffFIO { get; set; } = string.Empty; - public string StaffLogin { get; set; } = string.Empty; - public string StaffPassword { get; set; } = string.Empty; - public string StaffEmail { get; set; } = string.Empty; - public string StaffPhone { get; set; } = string.Empty; - } -} diff --git a/BeautyStudio/BeautyStudioContracts/BusinessLogicContracts/IClientLogic.cs b/BeautyStudio/BeautyStudioContracts/BusinessLogicContracts/IClientLogic.cs deleted file mode 100644 index 7f01a77..0000000 --- a/BeautyStudio/BeautyStudioContracts/BusinessLogicContracts/IClientLogic.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Collections.Generic; -using BeautyStudioContracts.BindingModels; -using BeautyStudioContracts.ViewModels; -using BeautyStudioContracts.SearchModels; - -namespace BeautyStudioContracts.BusinessLogicContracts -{ - public interface IClientLogic - { - List? ReadList(ClientSearchModel? model); - ClientViewModel? ReadElement(ClientSearchModel model); - bool Create(ClientBindingModel model); - bool Update(ClientBindingModel model); - bool Delete(ClientBindingModel model); - } -} diff --git a/BeautyStudio/BeautyStudioContracts/BusinessLogicContracts/IOrderLogic.cs b/BeautyStudio/BeautyStudioContracts/BusinessLogicContracts/IOrderLogic.cs index a24537e..bb34e67 100644 --- a/BeautyStudio/BeautyStudioContracts/BusinessLogicContracts/IOrderLogic.cs +++ b/BeautyStudio/BeautyStudioContracts/BusinessLogicContracts/IOrderLogic.cs @@ -12,5 +12,9 @@ namespace BeautyStudioContracts.BusinessLogicContracts bool Create(OrderBindingModel model); bool Delete(OrderBindingModel model); bool Update(OrderBindingModel model); + + bool TakeOrderInWork(OrderBindingModel model); + bool FinishOrder(OrderBindingModel model); + bool DeliveryOrder(OrderBindingModel model); } } diff --git a/BeautyStudio/BeautyStudioContracts/BusinessLogicContracts/IStaffLogic.cs b/BeautyStudio/BeautyStudioContracts/BusinessLogicContracts/IStaffLogic.cs deleted file mode 100644 index d0f9a91..0000000 --- a/BeautyStudio/BeautyStudioContracts/BusinessLogicContracts/IStaffLogic.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Collections.Generic; -using BeautyStudioContracts.BindingModels; -using BeautyStudioContracts.ViewModels; -using BeautyStudioContracts.SearchModels; - -namespace BeautyStudioContracts.BusinessLogicContracts -{ - public interface IStaffLogic - { - List? ReadList(StaffSearchModel? model); - StaffViewModel? ReadElement(StaffSearchModel model); - bool Create(StaffBindingModel model); - bool Update(StaffBindingModel model); - bool Delete(StaffBindingModel model); - } -} diff --git a/BeautyStudio/BeautyStudioContracts/SearchModels/ClientSearchModel.cs b/BeautyStudio/BeautyStudioContracts/SearchModels/ClientSearchModel.cs deleted file mode 100644 index 19630a7..0000000 --- a/BeautyStudio/BeautyStudioContracts/SearchModels/ClientSearchModel.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BeautyStudioContracts.SearchModels -{ - public class ClientSearchModel - { - public int? Id { get; set; } - public string? ClientFIO { get; set; } - public string? ClientEmail { get; set; } - public string? ClientPhone { get; set; } - public string? ClientLogin { get; set; } - public string? ClientPassword { get; set; } - } -} diff --git a/BeautyStudio/BeautyStudioContracts/SearchModels/CosmeticSearchModel.cs b/BeautyStudio/BeautyStudioContracts/SearchModels/CosmeticSearchModel.cs index c35bdfb..a61ba90 100644 --- a/BeautyStudio/BeautyStudioContracts/SearchModels/CosmeticSearchModel.cs +++ b/BeautyStudio/BeautyStudioContracts/SearchModels/CosmeticSearchModel.cs @@ -10,7 +10,6 @@ namespace BeautyStudioContracts.SearchModels { public int? Id { get; set; } public string? CosmeticName { get; set; } - public int? StoreKeeperId { get; set; } public int? LaborCostId { get; set; } } } diff --git a/BeautyStudio/BeautyStudioContracts/SearchModels/LaborCostSearchModel.cs b/BeautyStudio/BeautyStudioContracts/SearchModels/LaborCostSearchModel.cs index ed31551..5bd7228 100644 --- a/BeautyStudio/BeautyStudioContracts/SearchModels/LaborCostSearchModel.cs +++ b/BeautyStudio/BeautyStudioContracts/SearchModels/LaborCostSearchModel.cs @@ -10,6 +10,7 @@ namespace BeautyStudioContracts.SearchModels { public int? Id { get; set; } public int? TimeSpent { get; set; } - public int? StaffId { get; set; } + public string? Difficulty { get; set; } + public int? StoreKeeperId { get; set; } } } diff --git a/BeautyStudio/BeautyStudioContracts/SearchModels/OrderSearchModel.cs b/BeautyStudio/BeautyStudioContracts/SearchModels/OrderSearchModel.cs index e2b02f1..5e71b64 100644 --- a/BeautyStudio/BeautyStudioContracts/SearchModels/OrderSearchModel.cs +++ b/BeautyStudio/BeautyStudioContracts/SearchModels/OrderSearchModel.cs @@ -15,8 +15,7 @@ namespace BeautyStudioContracts.SearchModels public DateTime? DateCreate { get; set; } public DateTime? DateComplete { get; set; } public OrderStatus? Status { get; set; } - public int? ClientId { get; set; } public int? ServiceId { get; set; } - public int? StaffId { get; set; } + public int? CosmeticId { get; set; } } } diff --git a/BeautyStudio/BeautyStudioContracts/SearchModels/ProcedureSearchModel.cs b/BeautyStudio/BeautyStudioContracts/SearchModels/ProcedureSearchModel.cs index a1beadb..8475ed5 100644 --- a/BeautyStudio/BeautyStudioContracts/SearchModels/ProcedureSearchModel.cs +++ b/BeautyStudio/BeautyStudioContracts/SearchModels/ProcedureSearchModel.cs @@ -12,5 +12,6 @@ namespace BeautyStudioContracts.SearchModels public string? ProcedureName { get; set; } public double? ProcedureCost { get; set; } public string? ProcedureDescription { get; set; } + } } diff --git a/BeautyStudio/BeautyStudioContracts/SearchModels/ServiceSearchModel.cs b/BeautyStudio/BeautyStudioContracts/SearchModels/ServiceSearchModel.cs index da0c251..b65550f 100644 --- a/BeautyStudio/BeautyStudioContracts/SearchModels/ServiceSearchModel.cs +++ b/BeautyStudio/BeautyStudioContracts/SearchModels/ServiceSearchModel.cs @@ -10,7 +10,7 @@ namespace BeautyStudioContracts.SearchModels { public int? Id { get; set; } public string? ServiceName { get; set; } - public double? Sum { get; set; } - public int? StaffId { get; set; } + public double? ServicePrice { get; set; } + public int? StoreKeeperId { get; set; } } } diff --git a/BeautyStudio/BeautyStudioContracts/SearchModels/StaffSearchModel.cs b/BeautyStudio/BeautyStudioContracts/SearchModels/StaffSearchModel.cs deleted file mode 100644 index 24fa030..0000000 --- a/BeautyStudio/BeautyStudioContracts/SearchModels/StaffSearchModel.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BeautyStudioContracts.SearchModels -{ - public class StaffSearchModel - { - public int? Id { get; set; } - public string? StaffFIO { get; set; } - public string? StaffLogin { get; set; } - public string? StaffPassword { get; set; } - public string? StaffEmail { get; set; } - public string? StaffPhone { get; } - } -} diff --git a/BeautyStudio/BeautyStudioContracts/StoragesContracts/IClientStorage.cs b/BeautyStudio/BeautyStudioContracts/StoragesContracts/IClientStorage.cs deleted file mode 100644 index 1696b82..0000000 --- a/BeautyStudio/BeautyStudioContracts/StoragesContracts/IClientStorage.cs +++ /dev/null @@ -1,21 +0,0 @@ -using BeautyStudioContracts.BindingModels; -using BeautyStudioContracts.SearchModels; -using BeautyStudioContracts.ViewModels; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BeautyStudioContracts.StoragesContracts -{ - public interface IClientStorage - { - List GetFullList(); - List GetFilteredList(ClientSearchModel model); - ClientViewModel? GetElement(ClientSearchModel model); - ClientViewModel? Insert(ClientBindingModel model); - ClientViewModel? Update(ClientBindingModel model); - ClientViewModel? Delete(ClientBindingModel model); - } -} diff --git a/BeautyStudio/BeautyStudioContracts/StoragesContracts/ICosmeticStorage.cs b/BeautyStudio/BeautyStudioContracts/StoragesContracts/ICosmeticStorage.cs index 5fe7126..fe30cdb 100644 --- a/BeautyStudio/BeautyStudioContracts/StoragesContracts/ICosmeticStorage.cs +++ b/BeautyStudio/BeautyStudioContracts/StoragesContracts/ICosmeticStorage.cs @@ -17,5 +17,6 @@ namespace BeautyStudioContracts.StoragesContracts CosmeticViewModel? Insert(CosmeticBindingModel model); CosmeticViewModel? Update(CosmeticBindingModel model); CosmeticViewModel? Delete(CosmeticBindingModel model); + List GetCosmeticProcedures(CosmeticSearchModel model); } } diff --git a/BeautyStudio/BeautyStudioContracts/StoragesContracts/IProcedureStorage.cs b/BeautyStudio/BeautyStudioContracts/StoragesContracts/IProcedureStorage.cs index e345f10..0d11dd1 100644 --- a/BeautyStudio/BeautyStudioContracts/StoragesContracts/IProcedureStorage.cs +++ b/BeautyStudio/BeautyStudioContracts/StoragesContracts/IProcedureStorage.cs @@ -17,5 +17,6 @@ namespace BeautyStudioContracts.StoragesContracts ProcedureViewModel? Insert(ProcedureBindingModel model); ProcedureViewModel? Update(ProcedureBindingModel model); ProcedureViewModel? Delete(ProcedureBindingModel model); + List GetProcedureCosmetics(ProcedureSearchModel model); } } diff --git a/BeautyStudio/BeautyStudioContracts/StoragesContracts/IServiceStorage.cs b/BeautyStudio/BeautyStudioContracts/StoragesContracts/IServiceStorage.cs index 419509b..619b961 100644 --- a/BeautyStudio/BeautyStudioContracts/StoragesContracts/IServiceStorage.cs +++ b/BeautyStudio/BeautyStudioContracts/StoragesContracts/IServiceStorage.cs @@ -17,5 +17,6 @@ namespace BeautyStudioContracts.StoragesContracts ServiceViewModel? Insert(ServiceBindingModel model); ServiceViewModel? Update(ServiceBindingModel model); ServiceViewModel? Delete(ServiceBindingModel model); + } } diff --git a/BeautyStudio/BeautyStudioContracts/StoragesContracts/IStaffStorage.cs b/BeautyStudio/BeautyStudioContracts/StoragesContracts/IStaffStorage.cs deleted file mode 100644 index e272d01..0000000 --- a/BeautyStudio/BeautyStudioContracts/StoragesContracts/IStaffStorage.cs +++ /dev/null @@ -1,21 +0,0 @@ -using BeautyStudioContracts.BindingModels; -using BeautyStudioContracts.SearchModels; -using BeautyStudioContracts.ViewModels; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BeautyStudioContracts.StoragesContracts -{ - public interface IStaffStorage - { - List GetFullList(); - List GetFilteredList(StaffSearchModel model); - StaffViewModel? GetElement(StaffSearchModel model); - StaffViewModel? Insert(StaffBindingModel model); - StaffViewModel? Update(StaffBindingModel model); - StaffViewModel? Delete(StaffBindingModel model); - } -} diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/ClientViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/ClientViewModel.cs deleted file mode 100644 index 682f439..0000000 --- a/BeautyStudio/BeautyStudioContracts/ViewModels/ClientViewModel.cs +++ /dev/null @@ -1,30 +0,0 @@ -using BeautyStudioDataModels.Models; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BeautyStudioContracts.ViewModels -{ - public class ClientViewModel : IClientModel - { - public int Id { get; set; } - - [DisplayName("ФИО клиента")] - public string ClientFIO { get; set; } = string.Empty; - - [DisplayName("Электронная почта клиента")] - public string ClientEmail { get; set; } = string.Empty; - - [DisplayName("Номер телефона клиента")] - public string ClientPhone { get; set; } = string.Empty; - - [DisplayName("Логин клиента")] - public string ClientLogin { get; set; } = string.Empty; - - [DisplayName("Пароль клиента")] - public string ClientPassword { get; set; } = string.Empty; - } -} diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/CosmeticProcedureViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/CosmeticProcedureViewModel.cs new file mode 100644 index 0000000..50d805a --- /dev/null +++ b/BeautyStudio/BeautyStudioContracts/ViewModels/CosmeticProcedureViewModel.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautyStudioContracts.ViewModels +{ + public class CosmeticProcedureViewModel + { + public CosmeticViewModel Cosmetic { get; set; } = null!; + public ProcedureViewModel Procedure { get; set; } = null!; + public int Count { get; set; } + + public CosmeticProcedureViewModel() { } + + public CosmeticProcedureViewModel(CosmeticViewModel cosmetic, ProcedureViewModel procedure, int count) + { + Cosmetic = cosmetic; + Procedure = procedure; + Count = count; + } + } +} diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/CosmeticViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/CosmeticViewModel.cs index e1b6ba1..3035f35 100644 --- a/BeautyStudio/BeautyStudioContracts/ViewModels/CosmeticViewModel.cs +++ b/BeautyStudio/BeautyStudioContracts/ViewModels/CosmeticViewModel.cs @@ -21,5 +21,8 @@ namespace BeautyStudioContracts.ViewModels public int StoreKeeperId { get; set; } public int LaborCostId { get; set; } + + public List ServiceCosmetic { get; set; } = new(); + public List CosmeticProcedure { get; set; } = new(); } } diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/LaborCostViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/LaborCostViewModel.cs index a46f912..55b6745 100644 --- a/BeautyStudio/BeautyStudioContracts/ViewModels/LaborCostViewModel.cs +++ b/BeautyStudio/BeautyStudioContracts/ViewModels/LaborCostViewModel.cs @@ -11,9 +11,11 @@ namespace BeautyStudioContracts.ViewModels public class LaborCostViewModel : ILaborCostModel { public int Id { get; set; } - [DisplayName("Потрачено времени (часов)")] public int TimeSpent { get; set; } - public int StaffId { get; set; } + + [DisplayName("Сложность")] + public string Difficulty { get; set; } = string.Empty; + public int StoreKeeperId { get; set; } } } diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/OrderCosmeticViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/OrderCosmeticViewModel.cs new file mode 100644 index 0000000..1141364 --- /dev/null +++ b/BeautyStudio/BeautyStudioContracts/ViewModels/OrderCosmeticViewModel.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautyStudioContracts.ViewModels +{ + public class OrderCosmeticViewModel + { + public CosmeticViewModel Cosmetic { get; set; } = null!; + + public OrderCosmeticViewModel() { } + + public OrderCosmeticViewModel(CosmeticViewModel cosmetic) + { + Cosmetic = cosmetic; + } + } +} diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/OrderProcedureViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/OrderProcedureViewModel.cs new file mode 100644 index 0000000..2d9d772 --- /dev/null +++ b/BeautyStudio/BeautyStudioContracts/ViewModels/OrderProcedureViewModel.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautyStudioContracts.ViewModels +{ + public class OrderProcedureViewModel + { + public ProcedureViewModel Procedure { get; set; } = null!; + public int Count { get; set; } + + public OrderProcedureViewModel() { } + + public OrderProcedureViewModel(ProcedureViewModel procedure, int count) + { + Procedure = procedure; + Count = count; + } + } +} diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/OrderServiceViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/OrderServiceViewModel.cs new file mode 100644 index 0000000..39c25db --- /dev/null +++ b/BeautyStudio/BeautyStudioContracts/ViewModels/OrderServiceViewModel.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautyStudioContracts.ViewModels +{ + public class OrderServiceViewModel + { + public ServiceViewModel Service { get; set; } = null!; + public int Count { get; set; } + + public OrderServiceViewModel() { } + + public OrderServiceViewModel(ServiceViewModel service, int count) + { + Service = service; + Count = count; + } + } +} diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/OrderViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/OrderViewModel.cs index fc2fa2c..6039b51 100644 --- a/BeautyStudio/BeautyStudioContracts/ViewModels/OrderViewModel.cs +++ b/BeautyStudio/BeautyStudioContracts/ViewModels/OrderViewModel.cs @@ -12,13 +12,7 @@ namespace BeautyStudioContracts.ViewModels public class OrderViewModel : IOrderModel { public int Id { get; set; } - - [DisplayName("ФИО клиента")] - public string ClientFIO { get; set; } = string.Empty; - public int ClientId { get; set; } - [DisplayName("ФИО специалиста")] - public string? StaffFIO { get; set; } = null; - public int? StaffId { get; set; } + public int CosmeticId { get; set; } public int ServiceId { get; set; } @@ -36,5 +30,9 @@ namespace BeautyStudioContracts.ViewModels [DisplayName("Дата выполнения")] public DateTime? DateComplete { get; set; } + + public List OrderService { get; set; } = new(); + public List OrderCosmetic { get; set; } = new(); + public List OrderProcedure { get; set; } = new(); } } diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/ProcedureViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/ProcedureViewModel.cs index 82846e5..92d0b82 100644 --- a/BeautyStudio/BeautyStudioContracts/ViewModels/ProcedureViewModel.cs +++ b/BeautyStudio/BeautyStudioContracts/ViewModels/ProcedureViewModel.cs @@ -11,6 +11,7 @@ namespace BeautyStudioContracts.ViewModels public class ProcedureViewModel : IProcedureModel { public int Id { get; set; } + [DisplayName("Наименование процедуры")] public string ProcedureName { get; set; } = string.Empty; [DisplayName("Стоимость процедуры")] diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/ServiceCosmeticViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/ServiceCosmeticViewModel.cs new file mode 100644 index 0000000..63e1aaa --- /dev/null +++ b/BeautyStudio/BeautyStudioContracts/ViewModels/ServiceCosmeticViewModel.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautyStudioContracts.ViewModels +{ + public class ServiceCosmeticViewModel + { + public CosmeticViewModel Cosmetic { get; set; } = null!; + public ServiceViewModel Service { get; set; } = null!; + public int Count { get; set; } + + public ServiceCosmeticViewModel() { } + + public ServiceCosmeticViewModel(CosmeticViewModel cosmetic, ServiceViewModel service, int count) + { + Cosmetic = cosmetic; + Service = service; + Count = count; + } + } +} diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/ServiceProcedureViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/ServiceProcedureViewModel.cs new file mode 100644 index 0000000..8fa1a0c --- /dev/null +++ b/BeautyStudio/BeautyStudioContracts/ViewModels/ServiceProcedureViewModel.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautyStudioContracts.ViewModels +{ + public class ServiceProcedureViewModel + { + public ProcedureViewModel Procedure { get; set; } = null!; + public int Count { get; set; } + + public ServiceProcedureViewModel() { } + + public ServiceProcedureViewModel(ProcedureViewModel procedure, int count) + { + Procedure = procedure; + Count = count; + } + } +} diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/ServiceProceduresViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/ServiceProceduresViewModel.cs deleted file mode 100644 index b560d36..0000000 --- a/BeautyStudio/BeautyStudioContracts/ViewModels/ServiceProceduresViewModel.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BeautyStudioContracts.ViewModels -{ - public class ServiceProceduresViewModel - { - public ServiceViewModel Service { get; set; } = new(); - public Dictionary Procedures { get; set; } = new(); - } -} diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/ServiceViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/ServiceViewModel.cs index d790708..16e54d9 100644 --- a/BeautyStudio/BeautyStudioContracts/ViewModels/ServiceViewModel.cs +++ b/BeautyStudio/BeautyStudioContracts/ViewModels/ServiceViewModel.cs @@ -16,10 +16,12 @@ namespace BeautyStudioContracts.ViewModels public string ServiceName { get; set; } = string.Empty; [DisplayName("Стоимость услуги")] - public double Sum { get; set; } + public double ServicePrice { get; set; } - public int StaffId { get; set; } + public int StoreKeeperId { get; set; } - public Dictionary Procedures { get; set; } = new(); + public List ServiceCosmetic { get; set; } = new(); + public List ServiceProcedure { get; set; } = new(); + public List OrderService { get; set; } = new(); } } diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/StaffViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/StaffViewModel.cs deleted file mode 100644 index 59437c9..0000000 --- a/BeautyStudio/BeautyStudioContracts/ViewModels/StaffViewModel.cs +++ /dev/null @@ -1,30 +0,0 @@ -using BeautyStudioDataModels.Models; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BeautyStudioContracts.ViewModels -{ - public class StaffViewModel : IStaffModel - { - public int Id { get; set; } - - [DisplayName("ФИО сотрудника")] - public string StaffFIO { get; set; } = string.Empty; - - [DisplayName("Логин сотрудника")] - public string StaffLogin { get; set; } = string.Empty; - - [DisplayName("Пароль сотрудника")] - public string StaffPassword { get; set; } = string.Empty; - - [DisplayName("Почта сотрудника")] - public string StaffEmail { get; set; } = string.Empty; - - [DisplayName("Телефон сотрудника")] - public string StaffPhone { get; set; } = string.Empty; - } -} diff --git a/BeautyStudio/BeautyStudioDataModels/BeautyStudioDataModels.csproj b/BeautyStudio/BeautyStudioDataModels/BeautyStudioDataModels.csproj index fa71b7a..ab71109 100644 --- a/BeautyStudio/BeautyStudioDataModels/BeautyStudioDataModels.csproj +++ b/BeautyStudio/BeautyStudioDataModels/BeautyStudioDataModels.csproj @@ -6,4 +6,8 @@ enable + + + + diff --git a/BeautyStudio/BeautyStudioDataModels/Enums/OrderStatus.cs b/BeautyStudio/BeautyStudioDataModels/Enums/OrderStatus.cs index d81f591..1908775 100644 --- a/BeautyStudio/BeautyStudioDataModels/Enums/OrderStatus.cs +++ b/BeautyStudio/BeautyStudioDataModels/Enums/OrderStatus.cs @@ -10,7 +10,7 @@ namespace BeautyStudioDataModels.Enums { Неизвестен = -1, Принято = 0, - Отклонено = 1, + Выполняется = 1, Выполнено = 2 } } diff --git a/BeautyStudio/BeautyStudioDataModels/Models/IClientModel.cs b/BeautyStudio/BeautyStudioDataModels/Models/IClientModel.cs deleted file mode 100644 index 2e3a808..0000000 --- a/BeautyStudio/BeautyStudioDataModels/Models/IClientModel.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BeautyStudioDataModels.Models -{ - public interface IClientModel : IId - { - string ClientFIO { get; } - string ClientEmail { get; } - string ClientPhone { get; } - string ClientLogin { get; set; } - string ClientPassword { get; } - } -} diff --git a/BeautyStudio/BeautyStudioDataModels/Models/ICosmeticModel.cs b/BeautyStudio/BeautyStudioDataModels/Models/ICosmeticModel.cs index 80a7852..c388005 100644 --- a/BeautyStudio/BeautyStudioDataModels/Models/ICosmeticModel.cs +++ b/BeautyStudio/BeautyStudioDataModels/Models/ICosmeticModel.cs @@ -10,7 +10,6 @@ namespace BeautyStudioDataModels.Models { string CosmeticName { get; } double CosmeticPrice { get; } - int StoreKeeperId { get; } int LaborCostId { get; } } } diff --git a/BeautyStudio/BeautyStudioDataModels/Models/ILaborCostModel.cs b/BeautyStudio/BeautyStudioDataModels/Models/ILaborCostModel.cs index 56ec203..8a9052f 100644 --- a/BeautyStudio/BeautyStudioDataModels/Models/ILaborCostModel.cs +++ b/BeautyStudio/BeautyStudioDataModels/Models/ILaborCostModel.cs @@ -9,6 +9,7 @@ namespace BeautyStudioDataModels.Models public interface ILaborCostModel : IId { int TimeSpent { get; } - int StaffId { get; } + string Difficulty { get; } + int StoreKeeperId { get; } } } diff --git a/BeautyStudio/BeautyStudioDataModels/Models/IOrderModel.cs b/BeautyStudio/BeautyStudioDataModels/Models/IOrderModel.cs index 8f4664e..cbd603a 100644 --- a/BeautyStudio/BeautyStudioDataModels/Models/IOrderModel.cs +++ b/BeautyStudio/BeautyStudioDataModels/Models/IOrderModel.cs @@ -13,9 +13,8 @@ namespace BeautyStudioDataModels.Models DateTime DateCreate { get; } DateTime? DateComplete { get; } OrderStatus Status { get; } - int ClientId { get; } int ServiceId { get; } - int? StaffId { get; } + int CosmeticId { get; } } } diff --git a/BeautyStudio/BeautyStudioDataModels/Models/IServiceModel.cs b/BeautyStudio/BeautyStudioDataModels/Models/IServiceModel.cs index f5e6cf3..a53dd68 100644 --- a/BeautyStudio/BeautyStudioDataModels/Models/IServiceModel.cs +++ b/BeautyStudio/BeautyStudioDataModels/Models/IServiceModel.cs @@ -10,7 +10,7 @@ namespace BeautyStudioDataModels.Models public interface IServiceModel : IId { string ServiceName { get; } - double Sum { get; } - int StaffId { get; } + double ServicePrice { get; } + int StoreKeeperId { get; set; } } } diff --git a/BeautyStudio/BeautyStudioDataModels/Models/IStaffModel.cs b/BeautyStudio/BeautyStudioDataModels/Models/IStaffModel.cs deleted file mode 100644 index b2f9146..0000000 --- a/BeautyStudio/BeautyStudioDataModels/Models/IStaffModel.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BeautyStudioDataModels.Models -{ - public interface IStaffModel : IId - { - string StaffFIO { get; } - string StaffLogin { get; } - string StaffPassword { get; } - string StaffEmail { get; } - string StaffPhone { get; } - } -} diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/BeautyStudioDatabase.cs b/BeautyStudio/BeautyStudioDatabaseImplement/BeautyStudioDatabase.cs index 0b8f44e..07de06f 100644 --- a/BeautyStudio/BeautyStudioDatabaseImplement/BeautyStudioDatabase.cs +++ b/BeautyStudio/BeautyStudioDatabaseImplement/BeautyStudioDatabase.cs @@ -16,15 +16,16 @@ namespace BeautyStudioDatabaseImplement } public virtual DbSet Orders { set; get; } - public virtual DbSet OrderService { set; get; } public virtual DbSet LaborCost { set; get; } public virtual DbSet Cosmetics { set; get; } public virtual DbSet Services { set; get; } - public virtual DbSet ServiceProcedures { set; get; } public virtual DbSet Procedures { set; get; } - public virtual DbSet ProcedureCosmetics { set; get; } - public virtual DbSet Staffs { set; get; } + public virtual DbSet ServiceCosmetics { set; get; } + public virtual DbSet ServiceProcedures { set; get; } + public virtual DbSet OrderCosmetics { set; get; } + public virtual DbSet OrderServices { set; get; } + public virtual DbSet OrderProcedures { set; get; } + public virtual DbSet CosmeticProcedures { set; get; } public virtual DbSet StoreKeepers { set; get; } - public virtual DbSet Clients { set; get; } } } diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/BeautyStudioDatabaseImplement.csproj b/BeautyStudio/BeautyStudioDatabaseImplement/BeautyStudioDatabaseImplement.csproj index 5d83c44..cdbdb5e 100644 --- a/BeautyStudio/BeautyStudioDatabaseImplement/BeautyStudioDatabaseImplement.csproj +++ b/BeautyStudio/BeautyStudioDatabaseImplement/BeautyStudioDatabaseImplement.csproj @@ -12,6 +12,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Implements/ClientStorage.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Implements/ClientStorage.cs deleted file mode 100644 index b87ba44..0000000 --- a/BeautyStudio/BeautyStudioDatabaseImplement/Implements/ClientStorage.cs +++ /dev/null @@ -1,97 +0,0 @@ -using BeautyStudioContracts.BindingModels; -using BeautyStudioContracts.SearchModels; -using BeautyStudioContracts.StoragesContracts; -using BeautyStudioContracts.ViewModels; -using BeautyStudioDatabaseImplement.Models; -using Microsoft.EntityFrameworkCore; -using System.Collections.Generic; -using System.Linq; - -namespace BeautyStudioDatabaseImplement.Implements -{ - public class ClientStorage : IClientStorage - { - public ClientViewModel? Delete(ClientBindingModel model) - { - using var context = new BeautyStudioDatabase(); - - var element = context.Clients.FirstOrDefault(rec => rec.Id == model.Id); - - if (element != null) - { - context.Clients.Remove(element); - context.SaveChanges(); - - return element.GetViewModel; - } - - return null; - } - - - public ClientViewModel? GetElement(ClientSearchModel model) - { - using var context = new BeautyStudioDatabase(); - if (model.Id.HasValue) - return context.Clients - .FirstOrDefault(x => x.Id == model.Id)? - .GetViewModel; - - if (!string.IsNullOrEmpty(model.ClientLogin) && - !string.IsNullOrEmpty(model.ClientPassword)) - return context.Clients - .FirstOrDefault(x => - x.ClientLogin.Equals(model.ClientLogin) && - x.ClientPassword.Equals(model.ClientPassword))? - .GetViewModel; - - return null; - } - - public List GetFilteredList(ClientSearchModel model) - { - throw new NotImplementedException(); - } - - public List GetFullList() - { - using var context = new BeautyStudioDatabase(); - return context.Clients - .Select(x => x.GetViewModel) - .ToList(); - } - - public ClientViewModel? Insert(ClientBindingModel model) - { - using var context = new BeautyStudioDatabase(); - - var newClient = Client.Create(model); - - if (newClient == null) - { - return null; - } - context.Clients.Add(newClient); - context.SaveChanges(); - - return newClient.GetViewModel; - } - - public ClientViewModel? Update(ClientBindingModel model) - { - using var context = new BeautyStudioDatabase(); - - var client = context.Clients.FirstOrDefault(x => x.Id == model.Id); - - if (client == null) - { - return null; - } - - client.Update(model); - context.SaveChanges(); - - return client.GetViewModel; - } - } -} \ No newline at end of file diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Implements/CosmeticStorage.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Implements/CosmeticStorage.cs index 392ecc7..855b9e2 100644 --- a/BeautyStudio/BeautyStudioDatabaseImplement/Implements/CosmeticStorage.cs +++ b/BeautyStudio/BeautyStudioDatabaseImplement/Implements/CosmeticStorage.cs @@ -16,8 +16,6 @@ namespace BeautyStudioDatabaseImplement.Implements { using var context = new BeautyStudioDatabase(); return context.Cosmetics - //.Include(x => x.Procedures) - //.ThenInclude(x => x.Procedure) .Select(x => x.GetViewModel) .ToList(); } @@ -38,7 +36,7 @@ namespace BeautyStudioDatabaseImplement.Implements .Select(x => x.GetViewModel) .ToList(); } - + return new(); } @@ -101,7 +99,7 @@ namespace BeautyStudioDatabaseImplement.Implements return new(); } using var context = new BeautyStudioDatabase(); - var procedures = context.ProcedureCosmetics + var procedures = context.CosmeticProcedures .Where(x => x.CosmeticId == model.Id) .Select(x => x.Procedure.GetViewModel) .ToList(); diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Implements/LaborCostStorage.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Implements/LaborCostStorage.cs index e7dfaf0..f405b4b 100644 --- a/BeautyStudio/BeautyStudioDatabaseImplement/Implements/LaborCostStorage.cs +++ b/BeautyStudio/BeautyStudioDatabaseImplement/Implements/LaborCostStorage.cs @@ -3,6 +3,11 @@ using BeautyStudioContracts.SearchModels; using BeautyStudioContracts.StoragesContracts; using BeautyStudioContracts.ViewModels; using BeautyStudioDatabaseImplement.Models; +using BeautyStudioContracts.BindingModels; +using BeautyStudioContracts.SearchModels; +using BeautyStudioContracts.StoragesContracts; +using BeautyStudioContracts.ViewModels; +using BeautyStudioDatabaseImplement.Models; using System; using System.Collections.Generic; using System.ComponentModel; @@ -35,10 +40,10 @@ namespace BeautyStudioDatabaseImplement.Implements } using var context = new BeautyStudioDatabase(); return context.LaborCost - .FirstOrDefault(x => x.Id == model.Id) + .FirstOrDefault(x => x.Id == model.Id) ?.GetViewModel; } - + public List GetFilteredList(LaborCostSearchModel model) { using var context = new BeautyStudioDatabase(); @@ -49,10 +54,10 @@ namespace BeautyStudioDatabaseImplement.Implements .Select(x => x.GetViewModel) .ToList(); } - if (model.StaffId.HasValue) + if (model.StoreKeeperId.HasValue) { return context.LaborCost - .Where(x => x.StaffId == model.StaffId) + .Where(x => x.StoreKeeperId == model.StoreKeeperId) .Select(x => x.GetViewModel) .ToList(); } @@ -83,14 +88,14 @@ namespace BeautyStudioDatabaseImplement.Implements public LaborCostViewModel? Update(LaborCostBindingModel model) { using var context = new BeautyStudioDatabase(); - var laborCosts = context.LaborCost.FirstOrDefault(x => x.Id == model.Id); - if (laborCosts == null) + var laborCost = context.LaborCost.FirstOrDefault(x => x.Id == model.Id); + if (laborCost == null) { return null; } - laborCosts.Update(model); + laborCost.Update(model); context.SaveChanges(); - return laborCosts.GetViewModel; + return laborCost.GetViewModel; } } } diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Implements/OrderStorage.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Implements/OrderStorage.cs index 6ecfdfc..ec84864 100644 --- a/BeautyStudio/BeautyStudioDatabaseImplement/Implements/OrderStorage.cs +++ b/BeautyStudio/BeautyStudioDatabaseImplement/Implements/OrderStorage.cs @@ -20,6 +20,8 @@ namespace BeautyStudioDatabaseImplement.Implements using var context = new BeautyStudioDatabase(); var element = context.Orders .Include(x => x.Services) + .Include(x => x.Procedures) + .Include(x => x.Cosmetics) .FirstOrDefault(rec => rec.Id == model.Id); if (element != null) { @@ -40,10 +42,14 @@ namespace BeautyStudioDatabaseImplement.Implements return context.Orders .Include(x => x.Services) .ThenInclude(x => x.Service) + .Include(x => x.Procedures) + .ThenInclude(x => x.Procedure) + .Include(x => x.Cosmetics) + .ThenInclude(x => x.Cosmetic) .FirstOrDefault(x => x.Id == model.Id) ?.GetViewModel; } - + public List GetFilteredList(OrderSearchModel model) { if (model == null) @@ -51,22 +57,16 @@ namespace BeautyStudioDatabaseImplement.Implements return new(); } using var context = new BeautyStudioDatabase(); - if (model.ClientId.HasValue && model.DateCreate.HasValue) + if (model.DateCreate.HasValue) { return context.Orders .Include(x => x.Services) .ThenInclude(x => x.Service) - .Where(x => x.ClientId == model.ClientId && - x.DateCreate == model.DateCreate).ToList() - .Select(x => x.GetViewModel) - .ToList(); - } - if (model.ClientId.HasValue) - { - return context.Orders - .Include(x => x.Services) - .ThenInclude(x => x.Service) - .Where(x => x.ClientId == model.ClientId) + .Include(x => x.Procedures) + .ThenInclude(x => x.Procedure) + .Include(x => x.Cosmetics) + .ThenInclude(x => x.Cosmetic) + .Where(x => x.DateCreate == model.DateCreate).ToList() .Select(x => x.GetViewModel) .ToList(); } @@ -79,6 +79,10 @@ namespace BeautyStudioDatabaseImplement.Implements return context.Orders .Include(x => x.Services) .ThenInclude(x => x.Service) + .Include(x => x.Procedures) + .ThenInclude(x => x.Procedure) + .Include(x => x.Cosmetics) + .ThenInclude(x => x.Cosmetic) .ToList() .Select(x => x.GetViewModel) .ToList(); @@ -110,6 +114,9 @@ namespace BeautyStudioDatabaseImplement.Implements } order.Update(model); context.SaveChanges(); + order.UpdateServices(context, model); + order.UpdateProcedures(context, model); + order.UpdateCosmetics(context, model); transaction.Commit(); return order.GetViewModel; } diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Implements/ProcedureStorage.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Implements/ProcedureStorage.cs index e6c359f..f0e8baf 100644 --- a/BeautyStudio/BeautyStudioDatabaseImplement/Implements/ProcedureStorage.cs +++ b/BeautyStudio/BeautyStudioDatabaseImplement/Implements/ProcedureStorage.cs @@ -43,7 +43,7 @@ namespace BeautyStudioDatabaseImplement.Implements (model.Id.HasValue && x.Id == model.Id)) ?.GetViewModel; } - + public List GetFilteredList(ProcedureSearchModel model) { using var context = new BeautyStudioDatabase(); @@ -93,6 +93,7 @@ namespace BeautyStudioDatabaseImplement.Implements } procedure.Update(model); context.SaveChanges(); + procedure.UpdateCosmetics(context, model); transaction.Commit(); return procedure.GetViewModel; } @@ -110,7 +111,7 @@ namespace BeautyStudioDatabaseImplement.Implements return new(); } using var context = new BeautyStudioDatabase(); - var cosmetics = context.ProcedureCosmetics + var cosmetics = context.CosmeticProcedures .Where(x => x.ProcedureId == model.Id) .Select(x => x.Cosmetic.GetViewModel) .ToList(); diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Implements/ServiceStorage.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Implements/ServiceStorage.cs index 2c1f7d6..17bcca9 100644 --- a/BeautyStudio/BeautyStudioDatabaseImplement/Implements/ServiceStorage.cs +++ b/BeautyStudio/BeautyStudioDatabaseImplement/Implements/ServiceStorage.cs @@ -19,6 +19,7 @@ namespace BeautyStudioDatabaseImplement.Implements using var context = new BeautyStudioDatabase(); var element = context.Services .Include(x => x.Procedures) + .Include(x => x.Cosmetics) .FirstOrDefault(rec => rec.Id == model.Id); if (element != null) { @@ -39,6 +40,8 @@ namespace BeautyStudioDatabaseImplement.Implements return context.Services .Include(x => x.Procedures) .ThenInclude(x => x.Procedure) + .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; @@ -56,17 +59,21 @@ namespace BeautyStudioDatabaseImplement.Implements return context.Services .Include(x => x.Procedures) .ThenInclude(x => x.Procedure) + .Include(x => x.Cosmetics) + .ThenInclude(x => x.Cosmetic) .Where(x => x.Id == model.Id) .ToList() .Select(x => x.GetViewModel) .ToList(); } - if (model.StaffId.HasValue) + if (model.StoreKeeperId.HasValue) { return context.Services .Include(x => x.Procedures) .ThenInclude(x => x.Procedure) - .Where(x => x.StaffId == model.StaffId) + .Include(x => x.Cosmetics) + .ThenInclude(x => x.Cosmetic) + .Where(x => x.StoreKeeperId == model.StoreKeeperId) .ToList() .Select(x => x.GetViewModel) .ToList(); @@ -80,6 +87,8 @@ namespace BeautyStudioDatabaseImplement.Implements return context.Services .Include(x => x.Procedures) .ThenInclude(x => x.Procedure) + .Include(x => x.Cosmetics) + .ThenInclude(x => x.Cosmetic) .Select(x => x.GetViewModel) .ToList(); } @@ -110,6 +119,8 @@ namespace BeautyStudioDatabaseImplement.Implements } service.Update(model); context.SaveChanges(); + service.UpdateCosmetics(context, model); + service.UpdateProcedures(context, model); transaction.Commit(); return service.GetViewModel; } diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Implements/StaffStorage.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Implements/StaffStorage.cs deleted file mode 100644 index f18ee5a..0000000 --- a/BeautyStudio/BeautyStudioDatabaseImplement/Implements/StaffStorage.cs +++ /dev/null @@ -1,97 +0,0 @@ -using BeautyStudioContracts.BindingModels; -using BeautyStudioContracts.SearchModels; -using BeautyStudioContracts.StoragesContracts; -using BeautyStudioContracts.ViewModels; -using BeautyStudioDatabaseImplement.Models; -using Microsoft.EntityFrameworkCore; -using System.Collections.Generic; -using System.Linq; - -namespace BeautyStudioDatabaseImplement.Implements -{ - public class StaffStorage : IStaffStorage - { - public StaffViewModel? Delete(StaffBindingModel model) - { - using var context = new BeautyStudioDatabase(); - - var element = context.Staffs.FirstOrDefault(rec => rec.Id == model.Id); - - if (element != null) - { - context.Staffs.Remove(element); - context.SaveChanges(); - - return element.GetViewModel; - } - - return null; - } - - public StaffViewModel? GetElement(StaffSearchModel model) - { - using var context = new BeautyStudioDatabase(); - if (model.Id.HasValue) - return context.Staffs - .FirstOrDefault(x => x.Id == model.Id)? - .GetViewModel; - - if (!string.IsNullOrEmpty(model.StaffPassword) && - !string.IsNullOrEmpty(model.StaffLogin)) - return context.Staffs - .FirstOrDefault(x => - x.StaffPassword.Equals(model.StaffPassword) && - x.StaffLogin.Equals(model.StaffLogin))? - .GetViewModel; - - return null; - } - - public List GetFilteredList(StaffSearchModel model) - { - throw new NotImplementedException(); - } - - public List GetFullList() - { - using var context = new BeautyStudioDatabase(); - return context.Staffs - .Select(x => x.GetViewModel) - .ToList(); - } - - public StaffViewModel? Insert(StaffBindingModel model) - { - using var context = new BeautyStudioDatabase(); - - var newStaffs = Staff.Create(model); - - if (newStaffs == null) - { - return null; - } - - context.Staffs.Add(newStaffs); - context.SaveChanges(); - - return newStaffs.GetViewModel; - } - - public StaffViewModel? Update(StaffBindingModel model) - { - using var context = new BeautyStudioDatabase(); - - var Staffs = context.Staffs.FirstOrDefault(x => x.Id == model.Id); - - if (Staffs == null) - { - return null; - } - - Staffs.Update(model); - context.SaveChanges(); - - return Staffs.GetViewModel; - } - } -} diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Models/Client.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Models/Client.cs deleted file mode 100644 index b9ed321..0000000 --- a/BeautyStudio/BeautyStudioDatabaseImplement/Models/Client.cs +++ /dev/null @@ -1,68 +0,0 @@ -using BeautyStudioContracts.BindingModels; -using BeautyStudioContracts.ViewModels; -using BeautyStudioDataModels.Models; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; - -namespace BeautyStudioDatabaseImplement.Models -{ - public class Client : IClientModel - { - public int Id { get; set; } - - [Required] - public string ClientLogin { get; set; } = string.Empty; - - [Required] - public string ClientFIO { get; set; } = string.Empty; - [Required] - public string ClientEmail { get; set; } = string.Empty; - [Required] - public string ClientPhone { get; set; } = string.Empty; - [Required] - public string ClientPassword { get; set; } = string.Empty; - - //связь один-ко-многим клиента с заказами - [ForeignKey("ClientId")] - public virtual List Orders { get; set; } = new(); - - public static Client? Create(ClientBindingModel model) - { - - if (model == null) - { - return null; - } - return new Client() - { - Id = model.Id, - ClientLogin = model.ClientLogin, - ClientFIO = model.ClientFIO, - ClientEmail = model.ClientEmail, - ClientPassword = model.ClientPassword, - }; - } - - public void Update(ClientBindingModel model) - { - if (model == null) - { - return; - } - ClientLogin = model.ClientLogin; - ClientFIO = model.ClientFIO; - ClientEmail = model.ClientEmail; - ClientPassword = model.ClientPassword; - } - - public ClientViewModel GetViewModel => new() - { - Id = Id, - ClientLogin = ClientLogin, - ClientFIO = ClientFIO, - ClientEmail = ClientEmail, - ClientPassword = ClientPassword - }; - - } -} diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Models/Cosmetic.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Models/Cosmetic.cs index e737bf5..c953dfb 100644 --- a/BeautyStudio/BeautyStudioDatabaseImplement/Models/Cosmetic.cs +++ b/BeautyStudio/BeautyStudioDatabaseImplement/Models/Cosmetic.cs @@ -28,9 +28,15 @@ namespace BeautyStudioDatabaseImplement.Models public int LaborCostId { get; set; } public virtual LaborCost LaborCost { get; set; } = new(); + // связь многие-ко-многим заказов и косметики + [ForeignKey("CosmeticId")] + public virtual List Orders { get; set; } = new(); // связь многие-ко-многим косметики с процедурами [ForeignKey("CosmeticId")] - public virtual List Procedures { get; set; } = new(); + public virtual List Procedures { get; set; } = new(); + // связь многие-ко-многим косметики с процедурами + [ForeignKey("CosmeticId")] + public virtual List Services { get; set; } = new(); public static Cosmetic Create(CosmeticBindingModel model) { @@ -44,7 +50,6 @@ namespace BeautyStudioDatabaseImplement.Models Id = model.Id, CosmeticName = model.CosmeticName, CosmeticPrice = model.CosmeticPrice, - StoreKeeperId = model.StoreKeeperId, LaborCostId = model.LaborCostId }; } @@ -57,7 +62,6 @@ namespace BeautyStudioDatabaseImplement.Models } CosmeticName = model.CosmeticName; CosmeticPrice = model.CosmeticPrice; - StoreKeeperId = model.StoreKeeperId; LaborCostId = model.LaborCostId; } @@ -66,7 +70,6 @@ namespace BeautyStudioDatabaseImplement.Models Id = Id, CosmeticName = CosmeticName, CosmeticPrice = CosmeticPrice, - StoreKeeperId = StoreKeeperId, LaborCostId = LaborCostId }; } diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Models/ProcedureCosmetics.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Models/CosmeticProcedure.cs similarity index 94% rename from BeautyStudio/BeautyStudioDatabaseImplement/Models/ProcedureCosmetics.cs rename to BeautyStudio/BeautyStudioDatabaseImplement/Models/CosmeticProcedure.cs index 0626298..5bc4f62 100644 --- a/BeautyStudio/BeautyStudioDatabaseImplement/Models/ProcedureCosmetics.cs +++ b/BeautyStudio/BeautyStudioDatabaseImplement/Models/CosmeticProcedure.cs @@ -7,21 +7,21 @@ using System.Threading.Tasks; namespace BeautyStudioDatabaseImplement.Models { - public class ProcedureCosmetics + public class CosmeticProcedure { public int Id { get; set; } - [Required] - public int ProcedureId { get; set; } - [Required] public int CosmeticId { get; set; } + [Required] + public int ProcedureId { get; set; } + [Required] public int ProcedureCosmeticCount { get; set; } - public virtual Procedure Procedure { get; set; } = new(); - public virtual Cosmetic Cosmetic { get; set; } = new(); + + public virtual Procedure Procedure { get; set; } = new(); } } diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Models/LaborCost.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Models/LaborCost.cs index 9e433d2..11623e3 100644 --- a/BeautyStudio/BeautyStudioDatabaseImplement/Models/LaborCost.cs +++ b/BeautyStudio/BeautyStudioDatabaseImplement/Models/LaborCost.cs @@ -17,9 +17,9 @@ namespace BeautyStudioDatabaseImplement.Models [Required] public string Difficulty { get; set; } = string.Empty; - public int StaffId { get; set; } + public int StoreKeeperId { get; set; } - public virtual Staff Staff { get; set; } + public virtual StoreKeeper StoreKeeper { get; set; } // связь один-ко-многим трудозатрат с косметикой [ForeignKey("LaborCostId")] @@ -34,7 +34,7 @@ namespace BeautyStudioDatabaseImplement.Models return new LaborCost() { Id = model.Id, - StaffId = model.StaffId, + StoreKeeperId = model.StoreKeeperId, TimeSpent = model.TimeSpent }; } @@ -46,13 +46,14 @@ namespace BeautyStudioDatabaseImplement.Models return; } TimeSpent = model.TimeSpent; - + Difficulty = model.Difficulty; } public LaborCostViewModel GetViewModel => new() { Id = Id, - TimeSpent = TimeSpent + TimeSpent = TimeSpent, + Difficulty = Difficulty }; } diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Models/Order.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Models/Order.cs index 93968ef..f6fb269 100644 --- a/BeautyStudio/BeautyStudioDatabaseImplement/Models/Order.cs +++ b/BeautyStudio/BeautyStudioDatabaseImplement/Models/Order.cs @@ -28,26 +28,84 @@ namespace BeautyStudioDatabaseImplement.Models public double Sum { get; set; } [Required] - public int ClientId { get; set; } - - [Required] - public int? StaffId { get; set; } - + public int? StoreKeeperId { get; set; } [Required] public int ServiceId { get; set; } + [Required] + public int CosmeticId { get; set; } - // связь заказов и услуги многие-ко-многим + private List? _orderServices = null; + + private List? _orderCosmetics = null; + + private List? _orderProcedures = null; + + [NotMapped] + public List OrderServices + { + get + { + _orderServices ??= Services + .Select(pc => new OrderServiceViewModel(pc.Service.GetViewModel, pc.OrderServiceCount)) + .ToList(); + return _orderServices; + } + } + + [NotMapped] + public List OrderProcedures + { + get + { + _orderProcedures ??= Procedures + .Select(pc => new OrderProcedureViewModel(pc.Procedure.GetViewModel, pc.OrderProcedureCount)) + .ToList(); + return _orderProcedures; + } + } + + [NotMapped] + public List OrderCosmetics + { + get + { + _orderCosmetics ??= Cosmetics + .Select(pc => new OrderCosmeticViewModel(pc.Cosmetic.GetViewModel)) + .ToList(); + return _orderCosmetics; + } + } + // связь услуги и заказов многие - ко - многим [ForeignKey("OrderId")] public virtual List Services { get; set; } = new(); + [ForeignKey("OrderId")] + public virtual List Cosmetics { get; set; } = new(); + + [ForeignKey("OrderId")] + public virtual List Procedures { get; set; } = new(); + public static Order Create(BeautyStudioDatabase context, OrderBindingModel model) { return new Order() { Id = model.Id, DateCreate = model.DateCreate, - DateComplete = model.DateComplete, - ClientId = model.ClientId, + Sum = model.Sum, + Services = model.OrderService.Select(x => new OrderService() + { + Service = context.Services.First(y => y.Id == x.Service.Id), + OrderServiceCount = x.Count + }).ToList(), + Procedures = model.OrderProcedure.Select(x => new OrderProcedure() + { + Procedure = context.Procedures.First(y => y.Id == x.Procedure.Id), + OrderProcedureCount = x.Count + }).ToList(), + Cosmetics = model.OrderCosmetic.Select(x => new OrderCosmetic() + { + Cosmetic = context.Cosmetics.First(y => y.Id == x.Cosmetic.Id), + }).ToList() }; } @@ -55,15 +113,80 @@ namespace BeautyStudioDatabaseImplement.Models { Status = model.Status; DateCreate = model.DateCreate; - StaffId = model.StaffId; + DateComplete = model.DateComplete; } public OrderViewModel GetViewModel => new() { Id = Id, DateCreate = DateCreate, - ClientId = ClientId + DateComplete = DateComplete, + Sum = Sum, + OrderService = OrderServices, + OrderProcedure = OrderProcedures, + OrderCosmetic = OrderCosmetics }; + public void UpdateServices(BeautyStudioDatabase context, OrderBindingModel model) + { + var orderServices = context.OrderServices + .Where(x => x.OrderId == model.Id) + .ToList(); + context.OrderServices + .RemoveRange(orderServices); + var order = context.Orders.First(x => x.Id == Id); + foreach (var record in model.OrderService) + { + context.OrderServices.Add(new OrderService + { + Order = order, + Service = context.Services.First(x => x.Id == record.Service.Id), + OrderServiceCount = record.Count + }); + context.SaveChanges(); + } + _orderServices = null; + } + + public void UpdateProcedures(BeautyStudioDatabase context, OrderBindingModel model) + { + var orderProcedures = context.OrderProcedures + .Where(x => x.OrderId == model.Id) + .ToList(); + context.OrderProcedures + .RemoveRange(orderProcedures); + var order = context.Orders.First(x => x.Id == Id); + foreach (var record in model.OrderProcedure) + { + context.OrderProcedures.Add(new OrderProcedure + { + Order = order, + Procedure = context.Procedures.First(x => x.Id == record.Procedure.Id), + OrderProcedureCount = record.Count + }); + context.SaveChanges(); + } + _orderProcedures = null; + } + + public void UpdateCosmetics(BeautyStudioDatabase context, OrderBindingModel model) + { + var orderCosmetic = context.OrderCosmetics + .Where(x => x.OrderId == model.Id) + .ToList(); + context.OrderCosmetics + .RemoveRange(orderCosmetic); + var order = context.Orders.First(x => x.Id == Id); + foreach (var record in model.OrderCosmetic) + { + context.OrderCosmetics.Add(new OrderCosmetic + { + Order = order, + Cosmetic = context.Cosmetics.First(x => x.Id == record.Cosmetic.Id), + }); + context.SaveChanges(); + } + _orderCosmetics = null; + } } } diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Models/OrderCosmetic.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Models/OrderCosmetic.cs new file mode 100644 index 0000000..9e38d9b --- /dev/null +++ b/BeautyStudio/BeautyStudioDatabaseImplement/Models/OrderCosmetic.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautyStudioDatabaseImplement.Models +{ + public class OrderCosmetic + { + public int Id { get; set; } + + [Required] + public int OrderId { get; set; } + + [Required] + public int CosmeticId { get; set; } + + public virtual Order Order { get; set; } = new(); + + public virtual Cosmetic Cosmetic { get; set; } = new(); + } +} diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Models/OrderProcedure.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Models/OrderProcedure.cs new file mode 100644 index 0000000..358b8c7 --- /dev/null +++ b/BeautyStudio/BeautyStudioDatabaseImplement/Models/OrderProcedure.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautyStudioDatabaseImplement.Models +{ + public class OrderProcedure + { + public int Id { get; set; } + + [Required] + public int OrderId { get; set; } + + [Required] + public int ProcedureId { get; set; } + + [Required] + public int OrderProcedureCount { get; set; } + + public virtual Order Order { get; set; } = new(); + + public virtual Procedure Procedure { get; set; } = new(); + } +} diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Models/OrderService.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Models/OrderService.cs index 2dea377..39e11bd 100644 --- a/BeautyStudio/BeautyStudioDatabaseImplement/Models/OrderService.cs +++ b/BeautyStudio/BeautyStudioDatabaseImplement/Models/OrderService.cs @@ -17,8 +17,11 @@ namespace BeautyStudioDatabaseImplement.Models [Required] public int ServiceId { get; set; } - public virtual Order Order { get; set; } = new(); - public virtual Service Service { get; set; } = new(); + [Required] + public int OrderServiceCount { get; set; } + public virtual Order Order { get; set; } = new(); + + public virtual Service Service { get; set; } = new(); } } diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Models/Procedure.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Models/Procedure.cs index 6301ea9..44339ca 100644 --- a/BeautyStudio/BeautyStudioDatabaseImplement/Models/Procedure.cs +++ b/BeautyStudio/BeautyStudioDatabaseImplement/Models/Procedure.cs @@ -22,14 +22,13 @@ namespace BeautyStudioDatabaseImplement.Models public double ProcedureCost { get; set; } [Required] - public string ProcedureDescription { get; set; } + public string ProcedureDescription { get; set; } = string.Empty; - public int ClientId { get; set; } - public virtual Client Client { get; set; } = null!; + public int StoreKeeperId { get; set; } // связь процедур и косметики многие - ко - многим [ForeignKey("ProcedureId")] - public virtual List Cosmetics { get; set; } = new(); + public virtual List Cosmetics { get; set; } = new(); private List? _cosmeticProcedures = null; @@ -49,6 +48,10 @@ namespace BeautyStudioDatabaseImplement.Models [ForeignKey("ProcedureId")] public virtual List Services { get; set; } = new(); + // связь процедур и заказов многие - ко - многим + [ForeignKey("ProcedureId")] + public virtual List Orders { get; set; } = new(); + public static Procedure Create(BeautyStudioDatabase context, ProcedureBindingModel model) { return new Procedure() @@ -57,6 +60,11 @@ namespace BeautyStudioDatabaseImplement.Models ProcedureName = model.ProcedureName, ProcedureCost = model.ProcedureCost, ProcedureDescription = model.ProcedureDescription, + Cosmetics = model.ProcedureCosmetics.Select(x => new CosmeticProcedure() + { + Cosmetic = context.Cosmetics.First(y => y.Id == x.Cosmetic.Id), + ProcedureCosmeticCount = x.Count + }).ToList() }; } @@ -75,5 +83,25 @@ namespace BeautyStudioDatabaseImplement.Models ProcedureDescription = ProcedureDescription, }; + public void UpdateCosmetics(BeautyStudioDatabase context, ProcedureBindingModel model) + { + var procedureCosmetics = context.CosmeticProcedures + .Where(x => x.ProcedureId == model.Id) + .ToList(); + context.CosmeticProcedures + .RemoveRange(procedureCosmetics); + var procedure = context.Procedures.First(x => x.Id == Id); + foreach (var record in model.ProcedureCosmetics) + { + context.CosmeticProcedures.Add(new CosmeticProcedure + { + Procedure = procedure, + Cosmetic = context.Cosmetics.First(x => x.Id == record.Cosmetic.Id), + ProcedureCosmeticCount = record.Count + }); + context.SaveChanges(); + } + _cosmeticProcedures = null; + } } } diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Models/Service.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Models/Service.cs index a4bab47..e49ba26 100644 --- a/BeautyStudio/BeautyStudioDatabaseImplement/Models/Service.cs +++ b/BeautyStudio/BeautyStudioDatabaseImplement/Models/Service.cs @@ -22,40 +22,113 @@ namespace BeautyStudioDatabaseImplement.Models public string ServiceName { get; set; } = string.Empty; [Required] - public double Sum { get; set; } + public double ServicePrice { get; set; } - public int StaffId { get; set; } - public virtual Staff Staff { get; set; } + public int StoreKeeperId { get; set; } + public virtual StoreKeeper StoreKeeper { get; set; } - // связь многие-ко-многим услуг с заказами + // связь услуги и заказов многие - ко - многим [ForeignKey("ServiceId")] public virtual List Orders { get; set; } = new(); - // связь многие-ко-многим услуг с процедурами + // связь услуги и косметки многие - ко - многим + [ForeignKey("ServiceId")] + public virtual List Cosmetics { get; set; } = new(); + + // связь услуги и косметки многие - ко - многим [ForeignKey("ServiceId")] public virtual List Procedures { get; set; } = new(); + private List? _serviceProcedures = null; + + [NotMapped] + public List ServiceProcedures + { + get + { + _serviceProcedures ??= Procedures + .Select(pc => new ServiceProcedureViewModel(pc.Procedure.GetViewModel, pc.ServiceProcedureCount)) + .ToList(); + return _serviceProcedures; + } + } + + private List? _serviceCosmetics = null; + [NotMapped] + public List ServiceCosmetics + { + get + { + _serviceCosmetics ??= Cosmetics + .Select(pc => new ServiceCosmeticViewModel(pc.Cosmetic.GetViewModel, pc.Service.GetViewModel, pc.ServiceCosmeticCount)) + .ToList(); + return _serviceCosmetics; + } + } + public static Service Create(BeautyStudioDatabase context, ServiceBindingModel model) { return new Service() { Id = model.Id, ServiceName = model.ServiceName, - StaffId = model.StaffId + ServicePrice = model.ServicePrice }; } public void Update(ServiceBindingModel model) { ServiceName = model.ServiceName; - StaffId = model.StaffId; + ServicePrice = model.ServicePrice; } public ServiceViewModel GetViewModel => new() { Id = Id, ServiceName = ServiceName, - StaffId = StaffId + ServicePrice = ServicePrice }; + + public void UpdateCosmetics(BeautyStudioDatabase context, ServiceBindingModel model) + { + var serviceCosmetics = context.ServiceCosmetics + .Where(x => x.ServiceId == model.Id) + .ToList(); + context.ServiceCosmetics + .RemoveRange(serviceCosmetics); + var service = context.Services.First(x => x.Id == Id); + foreach (var record in model.ServiceCosmetic) + { + context.ServiceCosmetics.Add(new ServiceCosmetic + { + Service = service, + Cosmetic = context.Cosmetics.First(x => x.Id == record.Cosmetic.Id), + ServiceCosmeticCount = record.Count + }); + context.SaveChanges(); + } + _serviceCosmetics = null; + } + + public void UpdateProcedures(BeautyStudioDatabase context, ServiceBindingModel model) + { + var serviceProcedures = context.ServiceProcedures + .Where(x => x.ServiceId == model.Id) + .ToList(); + context.ServiceProcedures + .RemoveRange(serviceProcedures); + var service = context.Services.First(x => x.Id == Id); + foreach (var record in model.ServiceProcedure) + { + context.ServiceProcedures.Add(new ServiceProcedure + { + Service = service, + Procedure = context.Procedures.First(x => x.Id == record.Procedure.Id), + ServiceProcedureCount = record.Count + }); + context.SaveChanges(); + } + _serviceProcedures = null; + } } } diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Models/ServiceCosmetic.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Models/ServiceCosmetic.cs new file mode 100644 index 0000000..3a1e82d --- /dev/null +++ b/BeautyStudio/BeautyStudioDatabaseImplement/Models/ServiceCosmetic.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeautyStudioDatabaseImplement.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/BeautyStudio/BeautyStudioDatabaseImplement/Models/ServiceProcedure.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Models/ServiceProcedure.cs index 29f1022..9099cd5 100644 --- a/BeautyStudio/BeautyStudioDatabaseImplement/Models/ServiceProcedure.cs +++ b/BeautyStudio/BeautyStudioDatabaseImplement/Models/ServiceProcedure.cs @@ -16,7 +16,10 @@ namespace BeautyStudioDatabaseImplement.Models public int ServiceId { get; set; } [Required] - public int ProcedureId { get; set; } + public int ProcedureId { get; set; } + + [Required] + public int ServiceProcedureCount { get; set; } public virtual Service Service { get; set; } = new(); diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Models/Staff.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Models/Staff.cs deleted file mode 100644 index 0f1f707..0000000 --- a/BeautyStudio/BeautyStudioDatabaseImplement/Models/Staff.cs +++ /dev/null @@ -1,81 +0,0 @@ -using BeautyStudioContracts.BindingModels; -using BeautyStudioContracts.ViewModels; -using BeautyStudioDataModels.Models; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; - -namespace BeautyStudioDatabaseImplement.Models -{ - public class Staff : IStaffModel - { - public int Id { get; set; } - - [Required] - public string StaffFIO { get; set; } = string.Empty; - - [Required] - public string StaffEmail { get; set; } = string.Empty; - - [Required] - public string StaffLogin { get; set; } = string.Empty; - - [Required] - public string StaffPassword { get; set; } = string.Empty; - - [Required] - public string StaffPhone { get; set; } = string.Empty; - - //связь один-ко-многим с трудозатратами - [ForeignKey("StaffId")] - public virtual List LaborCost { get; set; } = new(); - - // связь один-ко-многим с услугами - [ForeignKey("StaffId")] - public virtual List Services { get; set; } = new(); - - // связь один-ко-многим с заказами - [ForeignKey("StaffId")] - public virtual List Orders { get; set; } = new(); - - public static Staff? Create(StaffBindingModel model) - { - - if (model == null) - { - return null; - } - return new Staff() - { - Id = model.Id, - StaffFIO = model.StaffFIO, - StaffLogin = model.StaffLogin, - StaffEmail = model.StaffEmail, - StaffPassword = model.StaffPassword, - StaffPhone = model.StaffPhone, - }; - } - - public void Update(StaffBindingModel model) - { - if (model == null) - { - return; - } - StaffFIO = model.StaffFIO; - StaffLogin = model.StaffLogin; - StaffEmail = model.StaffEmail; - StaffPassword = model.StaffPassword; - StaffPhone = model.StaffPhone; - } - - public StaffViewModel GetViewModel => new() - { - Id = Id, - StaffFIO = StaffFIO, - StaffLogin = StaffLogin, - StaffEmail = StaffEmail, - StaffPassword = StaffPassword, - StaffPhone = StaffPhone, - }; - } -} diff --git a/BeautyStudio/BeautyStudioView/BeautyStudioView.csproj b/BeautyStudio/BeautyStudioView/BeautyStudioView.csproj index 55e8a58..381be12 100644 --- a/BeautyStudio/BeautyStudioView/BeautyStudioView.csproj +++ b/BeautyStudio/BeautyStudioView/BeautyStudioView.csproj @@ -13,6 +13,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + @@ -20,4 +21,19 @@ + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/BeautyStudio/BeautyStudioView/Form1.cs b/BeautyStudio/BeautyStudioView/Form1.cs deleted file mode 100644 index 40f2a3d..0000000 --- a/BeautyStudio/BeautyStudioView/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace BeautyStudioView -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} diff --git a/BeautyStudio/BeautyStudioView/FormCosmetics.Designer.cs b/BeautyStudio/BeautyStudioView/FormCosmetics.Designer.cs new file mode 100644 index 0000000..84a116a --- /dev/null +++ b/BeautyStudio/BeautyStudioView/FormCosmetics.Designer.cs @@ -0,0 +1,112 @@ +namespace BeautyStudioView +{ + partial class FormCosmetics + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + dataGridViewCosmetics = new DataGridView(); + buttonAdd = new Button(); + buttonUpdate = new Button(); + buttonDelete = new Button(); + buttonRefresh = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridViewCosmetics).BeginInit(); + SuspendLayout(); + // + // dataGridViewCosmetics + // + dataGridViewCosmetics.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewCosmetics.Location = new Point(12, 12); + dataGridViewCosmetics.Name = "dataGridViewCosmetics"; + dataGridViewCosmetics.Size = new Size(590, 426); + dataGridViewCosmetics.TabIndex = 0; + // + // buttonAdd + // + buttonAdd.Location = new Point(622, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(166, 30); + buttonAdd.TabIndex = 1; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += this.buttonAdd_Click; + // + // buttonUpdate + // + buttonUpdate.Location = new Point(622, 56); + buttonUpdate.Name = "buttonUpdate"; + buttonUpdate.Size = new Size(166, 30); + buttonUpdate.TabIndex = 2; + buttonUpdate.Text = "Изменить"; + buttonUpdate.UseVisualStyleBackColor = true; + buttonUpdate.Click += this.buttonUpdate_Click; + // + // buttonDelete + // + buttonDelete.Location = new Point(622, 103); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new Size(166, 30); + buttonDelete.TabIndex = 3; + buttonDelete.Text = "Удалить"; + buttonDelete.UseVisualStyleBackColor = true; + buttonDelete.Click += this.buttonDelete_Click; + // + // buttonRefresh + // + buttonRefresh.Location = new Point(622, 152); + buttonRefresh.Name = "buttonRefresh"; + buttonRefresh.Size = new Size(166, 30); + buttonRefresh.TabIndex = 4; + buttonRefresh.Text = "Обновить"; + buttonRefresh.UseVisualStyleBackColor = true; + buttonRefresh.Click += this.buttonRefresh_Click; + // + // FormCosmetics + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(buttonRefresh); + Controls.Add(buttonDelete); + Controls.Add(buttonUpdate); + Controls.Add(buttonAdd); + Controls.Add(dataGridViewCosmetics); + Name = "FormCosmetics"; + Text = "Список косметики"; + Load += FormCosmetics_Load; + ((System.ComponentModel.ISupportInitialize)dataGridViewCosmetics).EndInit(); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridViewCosmetics; + private Button buttonAdd; + private Button buttonUpdate; + private Button buttonDelete; + private Button buttonRefresh; + } +} \ No newline at end of file diff --git a/BeautyStudio/BeautyStudioView/FormCosmetics.cs b/BeautyStudio/BeautyStudioView/FormCosmetics.cs new file mode 100644 index 0000000..bfaf13e --- /dev/null +++ b/BeautyStudio/BeautyStudioView/FormCosmetics.cs @@ -0,0 +1,115 @@ +using BeautyStudioContracts.BindingModels; +using BeautyStudioContracts.BusinessLogicContracts; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.CosmeticModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace BeautyStudioView +{ + public partial class FormCosmetics : Form + { + private readonly ILogger _logger; + + private readonly ICosmeticLogic _logic; + + public FormCosmetics(ILogger logger, ICosmeticLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormCosmetics_Load(object sender, EventArgs e) + { + LoadData(); + } + + private void LoadData() + { + try + { + var list = _logic.ReadList(null); + if (list != null) + { + dataGridViewCosmetics.DataSource = list; + dataGridViewCosmetics.Columns["Id"].Visible = false; + dataGridViewCosmetics.Columns["CosmeticsName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + } + _logger.LogInformation("Загрузка косметики"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки косметики"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonAdd_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormCreateCosmetic)); + if (service is FormCreateCosmetic form) + { + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + + private void buttonUpdate_Click(object sender, EventArgs e) + { + if (dataGridViewCosmetics.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormCreateCosmetic)); + if (service is FormCreateCosmetic form) + { + form.Id = Convert.ToInt32(dataGridViewCosmetics.SelectedRows[0].Cells["Id"].Value); + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + } + + private void buttonDelete_Click(object sender, EventArgs e) + { + if (dataGridViewCosmetics.SelectedRows.Count == 1) + { + if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + int id = Convert.ToInt32(dataGridViewCosmetics.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Удаление косметики"); + try + { + if (!_logic.Delete(new CosmeticBindingModel + { + Id = id + })) + { + throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления косметики"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } + + private void buttonRefresh_Click(object sender, EventArgs e) + { + LoadData(); + } + } +} diff --git a/BeautyStudio/BeautyStudioView/FormCosmetics.resx b/BeautyStudio/BeautyStudioView/FormCosmetics.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/BeautyStudio/BeautyStudioView/FormCosmetics.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/BeautyStudio/BeautyStudioView/FormCreateCosmetic.Designer.cs b/BeautyStudio/BeautyStudioView/FormCreateCosmetic.Designer.cs new file mode 100644 index 0000000..04bb0c3 --- /dev/null +++ b/BeautyStudio/BeautyStudioView/FormCreateCosmetic.Designer.cs @@ -0,0 +1,117 @@ +namespace BeautyStudioView +{ + partial class FormCreateCosmetic + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + labelCosmeticName = new Label(); + textBoxCosmeticName = new TextBox(); + textBoxСosmeticPrice = new TextBox(); + labelCosmeticPrice = new Label(); + buttonSave = new Button(); + buttonСancel = new Button(); + SuspendLayout(); + // + // labelCosmeticName + // + labelCosmeticName.AutoSize = true; + labelCosmeticName.Location = new Point(12, 9); + labelCosmeticName.Name = "labelCosmeticName"; + labelCosmeticName.Size = new Size(62, 15); + labelCosmeticName.TabIndex = 0; + labelCosmeticName.Text = "Название:"; + // + // textBoxCosmeticName + // + textBoxCosmeticName.Location = new Point(80, 6); + textBoxCosmeticName.Name = "textBoxCosmeticName"; + textBoxCosmeticName.Size = new Size(335, 23); + textBoxCosmeticName.TabIndex = 1; + // + // textBoxСosmeticPrice + // + textBoxСosmeticPrice.Location = new Point(80, 40); + textBoxСosmeticPrice.Name = "textBoxСosmeticPrice"; + textBoxСosmeticPrice.Size = new Size(163, 23); + textBoxСosmeticPrice.TabIndex = 3; + // + // labelCosmeticPrice + // + labelCosmeticPrice.AutoSize = true; + labelCosmeticPrice.Location = new Point(36, 43); + labelCosmeticPrice.Name = "labelCosmeticPrice"; + labelCosmeticPrice.Size = new Size(38, 15); + labelCosmeticPrice.TabIndex = 2; + labelCosmeticPrice.Text = "Цена:"; + // + // buttonSave + // + buttonSave.Location = new Point(247, 71); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(75, 23); + buttonSave.TabIndex = 4; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonСancel + // + buttonСancel.Location = new Point(337, 71); + buttonСancel.Name = "buttonСancel"; + buttonСancel.Size = new Size(75, 23); + buttonСancel.TabIndex = 5; + buttonСancel.Text = "Отмена"; + buttonСancel.UseVisualStyleBackColor = true; + buttonСancel.Click += buttonCancel_Click; + // + // FormCreateCosmetic + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(427, 103); + Controls.Add(buttonСancel); + Controls.Add(buttonSave); + Controls.Add(textBoxСosmeticPrice); + Controls.Add(labelCosmeticPrice); + Controls.Add(textBoxCosmeticName); + Controls.Add(labelCosmeticName); + Name = "FormCreateCosmetic"; + Text = "Создание косметики"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelCosmeticName; + private TextBox textBoxCosmeticName; + private TextBox textBoxСosmeticPrice; + private Label labelCosmeticPrice; + private Button buttonSave; + private Button buttonСancel; + } +} \ No newline at end of file diff --git a/BeautyStudio/BeautyStudioView/FormCreateCosmetic.cs b/BeautyStudio/BeautyStudioView/FormCreateCosmetic.cs new file mode 100644 index 0000000..01e1694 --- /dev/null +++ b/BeautyStudio/BeautyStudioView/FormCreateCosmetic.cs @@ -0,0 +1,95 @@ +using BeautyStudioContracts.BindingModels; +using BeautyStudioContracts.BusinessLogicContracts; +using BeautyStudioContracts.SearchModels; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace BeautyStudioView +{ + public partial class FormCreateCosmetic : Form + { + private readonly ILogger _logger; + private readonly ICosmeticLogic _logic; + private int? _id; + public int Id { set { _id = value; } } + + public FormCreateCosmetic(ILogger logger, ICosmeticLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormCreateCosmetic_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + try + { + _logger.LogInformation("Получение косметики"); + var view = _logic.ReadElement(new CosmeticSearchModel + { + Id = _id.Value + }); + if (view != null) + { + textBoxCosmeticName.Text = view.CosmeticName; + textBoxСosmeticPrice.Text = view.CosmeticPrice.ToString(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения косметики"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + + private void buttonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxCosmeticName.Text)) + { + MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Сохранение косметики"); + try + { + var model = new CosmeticBindingModel + { + Id = _id ?? 0, + CosmeticName = textBoxCosmeticName.Text, + CosmeticPrice = Convert.ToDouble(textBoxСosmeticPrice.Text) + }; + var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения косметики"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/BeautyStudio/BeautyStudioView/FormCreateCosmetic.resx b/BeautyStudio/BeautyStudioView/FormCreateCosmetic.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/BeautyStudio/BeautyStudioView/FormCreateCosmetic.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/BeautyStudio/BeautyStudioView/FormCreateOrder.Designer.cs b/BeautyStudio/BeautyStudioView/FormCreateOrder.Designer.cs new file mode 100644 index 0000000..c10adbf --- /dev/null +++ b/BeautyStudio/BeautyStudioView/FormCreateOrder.Designer.cs @@ -0,0 +1,39 @@ +namespace BeautyStudioView +{ + partial class FormCreateOrder + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Text = "FormCreateOrder"; + } + + #endregion + } +} \ No newline at end of file diff --git a/BeautyStudio/BeautyStudioView/FormCreateOrder.cs b/BeautyStudio/BeautyStudioView/FormCreateOrder.cs new file mode 100644 index 0000000..3e3ca5d --- /dev/null +++ b/BeautyStudio/BeautyStudioView/FormCreateOrder.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace BeautyStudioView +{ + public partial class FormCreateOrder : Form + { + public FormCreateOrder() + { + InitializeComponent(); + } + } +} diff --git a/BeautyStudio/BeautyStudioView/Form1.resx b/BeautyStudio/BeautyStudioView/FormCreateOrder.resx similarity index 100% rename from BeautyStudio/BeautyStudioView/Form1.resx rename to BeautyStudio/BeautyStudioView/FormCreateOrder.resx diff --git a/BeautyStudio/BeautyStudioView/Form1.Designer.cs b/BeautyStudio/BeautyStudioView/FormLabor.Designer.cs similarity index 79% rename from BeautyStudio/BeautyStudioView/Form1.Designer.cs rename to BeautyStudio/BeautyStudioView/FormLabor.Designer.cs index 65cc4c9..3e9f7c9 100644 --- a/BeautyStudio/BeautyStudioView/Form1.Designer.cs +++ b/BeautyStudio/BeautyStudioView/FormLabor.Designer.cs @@ -1,14 +1,14 @@ namespace BeautyStudioView { - partial class Form1 + partial class FormLabor { /// - /// Required designer variable. + /// Required designer variable. /// private System.ComponentModel.IContainer components = null; /// - /// Clean up any resources being used. + /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) @@ -23,8 +23,8 @@ #region Windows Form Designer generated code /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. /// private void InitializeComponent() { @@ -36,4 +36,4 @@ #endregion } -} +} \ No newline at end of file diff --git a/BeautyStudio/BeautyStudioView/FormLabor.cs b/BeautyStudio/BeautyStudioView/FormLabor.cs new file mode 100644 index 0000000..25306d0 --- /dev/null +++ b/BeautyStudio/BeautyStudioView/FormLabor.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace BeautyStudioView +{ + public partial class FormLabor : Form + { + public FormLabor() + { + InitializeComponent(); + } + } +} diff --git a/BeautyStudio/BeautyStudioView/FormLabor.resx b/BeautyStudio/BeautyStudioView/FormLabor.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/BeautyStudio/BeautyStudioView/FormLabor.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/BeautyStudio/BeautyStudioView/FormMain.Designer.cs b/BeautyStudio/BeautyStudioView/FormMain.Designer.cs new file mode 100644 index 0000000..7356d9c --- /dev/null +++ b/BeautyStudio/BeautyStudioView/FormMain.Designer.cs @@ -0,0 +1,112 @@ +namespace BeautyStudioView +{ + partial class FormMain + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMain)); + toolStrip1 = new ToolStrip(); + ordersToolStrip = new ToolStripDropDownButton(); + toolStripDropDownButton1 = new ToolStripDropDownButton(); + списокУслугToolStripMenuItem = new ToolStripMenuItem(); + списокПроцедурПоКосметикеToolStripMenuItem = new ToolStripMenuItem(); + списокУслугПоЗаказамИТрудозатратамToolStripMenuItem = new ToolStripMenuItem(); + toolStrip1.SuspendLayout(); + SuspendLayout(); + // + // toolStrip1 + // + toolStrip1.Items.AddRange(new ToolStripItem[] { ordersToolStrip, toolStripDropDownButton1 }); + toolStrip1.Location = new Point(0, 0); + toolStrip1.Name = "toolStrip1"; + toolStrip1.Size = new Size(1047, 25); + toolStrip1.TabIndex = 0; + toolStrip1.Text = "toolStrip1"; + // + // ordersToolStrip + // + ordersToolStrip.DisplayStyle = ToolStripItemDisplayStyle.Text; + ordersToolStrip.Image = (Image)resources.GetObject("ordersToolStrip.Image"); + ordersToolStrip.ImageAlign = ContentAlignment.MiddleRight; + ordersToolStrip.ImageTransparentColor = Color.Magenta; + ordersToolStrip.Name = "ordersToolStrip"; + ordersToolStrip.Size = new Size(59, 22); + ordersToolStrip.Text = "Заказы"; + // + // toolStripDropDownButton1 + // + toolStripDropDownButton1.DisplayStyle = ToolStripItemDisplayStyle.Text; + toolStripDropDownButton1.DropDownItems.AddRange(new ToolStripItem[] { списокУслугToolStripMenuItem, списокПроцедурПоКосметикеToolStripMenuItem, списокУслугПоЗаказамИТрудозатратамToolStripMenuItem }); + toolStripDropDownButton1.Image = (Image)resources.GetObject("toolStripDropDownButton1.Image"); + toolStripDropDownButton1.ImageTransparentColor = Color.Magenta; + toolStripDropDownButton1.Name = "toolStripDropDownButton1"; + toolStripDropDownButton1.Size = new Size(61, 22); + toolStripDropDownButton1.Text = "Отчёты"; + toolStripDropDownButton1.ToolTipText = "Отчёты"; + // + // списокУслугToolStripMenuItem + // + списокУслугToolStripMenuItem.Name = "списокУслугToolStripMenuItem"; + списокУслугToolStripMenuItem.Size = new Size(249, 22); + списокУслугToolStripMenuItem.Text = "Список услуг"; + // + // списокПроцедурПоКосметикеToolStripMenuItem + // + списокПроцедурПоКосметикеToolStripMenuItem.Name = "списокПроцедурПоКосметикеToolStripMenuItem"; + списокПроцедурПоКосметикеToolStripMenuItem.Size = new Size(249, 22); + списокПроцедурПоКосметикеToolStripMenuItem.Text = "Список процедур по косметике"; + // + // списокУслугПоЗаказамИТрудозатратамToolStripMenuItem + // + списокУслугПоЗаказамИТрудозатратамToolStripMenuItem.Name = "списокУслугПоЗаказамИТрудозатратамToolStripMenuItem"; + списокУслугПоЗаказамИТрудозатратамToolStripMenuItem.Size = new Size(304, 22); + списокУслугПоЗаказамИТрудозатратамToolStripMenuItem.Text = "Список услуг по заказам и трудозатратам"; + // + // FormMain + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1047, 450); + Controls.Add(toolStrip1); + Name = "FormMain"; + Text = "Учет услуг"; + toolStrip1.ResumeLayout(false); + toolStrip1.PerformLayout(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private ToolStrip toolStrip1; + private ToolStripDropDownButton ordersToolStrip; + private ToolStripDropDownButton toolStripDropDownButton1; + private ToolStripMenuItem списокУслугToolStripMenuItem; + private ToolStripMenuItem списокПроцедурПоКосметикеToolStripMenuItem; + private ToolStripMenuItem списокУслугПоЗаказамИТрудозатратамToolStripMenuItem; + } +} \ No newline at end of file diff --git a/BeautyStudio/BeautyStudioView/FormMain.cs b/BeautyStudio/BeautyStudioView/FormMain.cs new file mode 100644 index 0000000..31b2ff1 --- /dev/null +++ b/BeautyStudio/BeautyStudioView/FormMain.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace BeautyStudioView +{ + public partial class FormMain : Form + { + public FormMain() + { + InitializeComponent(); + } + + private void toolStripTextBox1_Click(object sender, EventArgs e) + { + + } + } +} diff --git a/BeautyStudio/BeautyStudioView/FormMain.resx b/BeautyStudio/BeautyStudioView/FormMain.resx new file mode 100644 index 0000000..ffdf5f2 --- /dev/null +++ b/BeautyStudio/BeautyStudioView/FormMain.resx @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACRSURBVDhPY/j27dt/SjDYACcnJ7IwigEf3n8kCZNswPNb + J/+f6DYF0yA+yQac6Db5f6hWCmwIiE+mC0wIu2DS2Vf/F1x6DefjwlgNyNr34r/0wkdgTMgQDAOQNRNj + CIoBOg0rMTTDMLIhIHbriZeYBmDTiIxBGkEYxge5liQDsGGQqykyAISpZwAlmIEywMAAAAc1/Jwvt6sN + AAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACRSURBVDhPY/j27dt/SjDYACcnJ7IwigEf3n8kCZNswPNb + J/+f6DYF0yA+yQac6Db5f6hWCmwIiE+mC0wIu2DS2Vf/F1x6DefjwlgNyNr34r/0wkdgTMgQDAOQNRNj + CIoBOg0rMTTDMLIhIHbriZeYBmDTiIxBGkEYxge5liQDsGGQqykyAISpZwAlmIEywMAAAAc1/Jwvt6sN + AAAAAElFTkSuQmCC + + + \ No newline at end of file diff --git a/BeautyStudio/BeautyStudioView/FormOrders.Designer.cs b/BeautyStudio/BeautyStudioView/FormOrders.Designer.cs new file mode 100644 index 0000000..ee8c0ee --- /dev/null +++ b/BeautyStudio/BeautyStudioView/FormOrders.Designer.cs @@ -0,0 +1,125 @@ +namespace BeautyStudioView +{ + partial class FormOrders + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + dataGridViewOrders = new DataGridView(); + buttonСreate = new Button(); + buttonWork = new Button(); + buttonReady = new Button(); + buttonIssued = new Button(); + buttonRefresh = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridViewOrders).BeginInit(); + SuspendLayout(); + // + // dataGridViewOrders + // + dataGridViewOrders.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewOrders.Location = new Point(12, 12); + dataGridViewOrders.Name = "dataGridViewOrders"; + dataGridViewOrders.Size = new Size(647, 426); + dataGridViewOrders.TabIndex = 0; + // + // buttonСreate + // + buttonСreate.Location = new Point(665, 113); + buttonСreate.Name = "buttonСreate"; + buttonСreate.Size = new Size(126, 23); + buttonСreate.TabIndex = 1; + buttonСreate.Text = "Создать заказ"; + buttonСreate.UseVisualStyleBackColor = true; + buttonСreate.Click += buttonCreate_Click; + // + // buttonWork + // + buttonWork.Location = new Point(665, 156); + buttonWork.Name = "buttonWork"; + buttonWork.Size = new Size(126, 39); + buttonWork.TabIndex = 2; + buttonWork.Text = "Отдать на выполнение"; + buttonWork.UseVisualStyleBackColor = true; + buttonWork.Click += buttonWork_Click; + // + // buttonReady + // + buttonReady.Location = new Point(665, 219); + buttonReady.Name = "buttonReady"; + buttonReady.Size = new Size(126, 23); + buttonReady.TabIndex = 3; + buttonReady.Text = "Заказ готов"; + buttonReady.UseVisualStyleBackColor = true; + buttonReady.Click += buttonReady_Click; + // + // buttonIssued + // + buttonIssued.Location = new Point(665, 259); + buttonIssued.Name = "buttonIssued"; + buttonIssued.Size = new Size(126, 23); + buttonIssued.TabIndex = 4; + buttonIssued.Text = "Заказ выдан"; + buttonIssued.UseVisualStyleBackColor = true; + buttonIssued.Click += buttonIssued_Click; + // + // buttonRefresh + // + buttonRefresh.Location = new Point(665, 301); + buttonRefresh.Name = "buttonRefresh"; + buttonRefresh.Size = new Size(123, 23); + buttonRefresh.TabIndex = 5; + buttonRefresh.Text = "Обновить список"; + buttonRefresh.UseVisualStyleBackColor = true; + buttonRefresh.Click += buttonRefresh_Click; + // + // FormOrders + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(buttonRefresh); + Controls.Add(buttonIssued); + Controls.Add(buttonReady); + Controls.Add(buttonWork); + Controls.Add(buttonСreate); + Controls.Add(dataGridViewOrders); + Name = "FormOrders"; + Text = "Заказы"; + Load += FormOrders_Load; + ((System.ComponentModel.ISupportInitialize)dataGridViewOrders).EndInit(); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridViewOrders; + private Button buttonСreate; + private Button buttonWork; + private Button buttonReady; + private Button buttonIssued; + private Button buttonRefresh; + } +} \ No newline at end of file diff --git a/BeautyStudio/BeautyStudioView/FormOrders.cs b/BeautyStudio/BeautyStudioView/FormOrders.cs new file mode 100644 index 0000000..cb53a35 --- /dev/null +++ b/BeautyStudio/BeautyStudioView/FormOrders.cs @@ -0,0 +1,133 @@ +using BeautyStudioContracts.BindingModels; +using BeautyStudioContracts.BusinessLogicContracts; +using BeautyStudioView; +using BeautyStudioBusinessLogic.BusinessLogic; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace BeautyStudioView +{ + public partial class FormOrders : Form + { + private readonly ILogger _logger; + private readonly IOrderLogic _orderLogic; + public FormOrders(ILogger logger, IOrderLogic orderLogic) + { + InitializeComponent(); + _logger = logger; + _orderLogic = orderLogic; + } + private void FormOrders_Load(object sender, EventArgs e) + { + LoadData(); + } + private void LoadData() + { + _logger.LogInformation("Загрузка заказов"); + // прописать логику + try + { + var list = _orderLogic.ReadList(null); + if (list != null) + { + dataGridViewOrders.DataSource = list; + dataGridViewOrders.Columns["ServiceId"].Visible = false; + } + _logger.LogInformation("Загрузка услуг"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки услуг"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void buttonCreate_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); + if (service is FormCreateOrder form) + { + form.ShowDialog(); + LoadData(); + } + } + private void buttonWork_Click(object sender, EventArgs e) + { + if (dataGridViewOrders.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridViewOrders.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); + try + { + var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка передачи заказа в работу"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void buttonReady_Click(object sender, EventArgs e) + { + if (dataGridViewOrders.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridViewOrders.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id); + try + { + var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о готовности заказа"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void buttonIssued_Click(object sender, EventArgs e) + { + if (dataGridViewOrders.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridViewOrders.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id); + try + { + var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + _logger.LogInformation("Заказ №{id} выдан", id); + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о выдачи заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + private void buttonRefresh_Click(object sender, EventArgs e) + { + LoadData(); + } + } +} diff --git a/BeautyStudio/BeautyStudioView/FormOrders.resx b/BeautyStudio/BeautyStudioView/FormOrders.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/BeautyStudio/BeautyStudioView/FormOrders.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/BeautyStudio/BeautyStudioView/Program.cs b/BeautyStudio/BeautyStudioView/Program.cs index 7c8fe23..78ffda0 100644 --- a/BeautyStudio/BeautyStudioView/Program.cs +++ b/BeautyStudio/BeautyStudioView/Program.cs @@ -1,7 +1,17 @@ +using BeautyStudioBusinessLogic.BusinessLogic; +using BeautyStudioBusinessLogic.BusinessLogics; +using BeautyStudioContracts.BusinessLogicContracts; +using BeautyStudioContracts.StoragesContracts; +using BeautyStudioDatabaseImplement.Implements; +using Microsoft.Extensions.DependencyInjection; +using NLog.Extensions.Logging; + namespace BeautyStudioView { internal static class Program { + private static ServiceProvider? _serviceProvider; + public static ServiceProvider? ServiceProvider => _serviceProvider; /// /// The main entry point for the application. /// @@ -11,7 +21,49 @@ namespace BeautyStudioView // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + var services = new ServiceCollection(); + ConfigureServices(services); + _serviceProvider = services.BuildServiceProvider(); + Application.Run(_serviceProvider.GetRequiredService()); + } + + private static void ConfigureServices(ServiceCollection services) + { + services.AddLogging(option => + { + option.SetMinimumLevel(LogLevel.Information); + option.AddNLog("nlog.config"); + }); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/BeautyStudio/BeautyStudioView/Properties/Resources.Designer.cs b/BeautyStudio/BeautyStudioView/Properties/Resources.Designer.cs new file mode 100644 index 0000000..f2cdf2d --- /dev/null +++ b/BeautyStudio/BeautyStudioView/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace BeautyStudioView.Properties { + using System; + + + /// + /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. + /// + // Этот класс создан автоматически классом StronglyTypedResourceBuilder + // с помощью такого средства, как ResGen или Visual Studio. + // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen + // с параметром /str или перестройте свой проект VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("BeautyStudioView.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Перезаписывает свойство CurrentUICulture текущего потока для всех + /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/BeautyStudio/BeautyStudioView/Properties/Resources.resx b/BeautyStudio/BeautyStudioView/Properties/Resources.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/BeautyStudio/BeautyStudioView/Properties/Resources.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file