diff --git a/FlowerShop/FlowerShopContracts/BindingModels/ImplementerBindingModel.cs b/FlowerShop/FlowerShopContracts/BindingModels/ImplementerBindingModel.cs new file mode 100644 index 0000000..b5ab22c --- /dev/null +++ b/FlowerShop/FlowerShopContracts/BindingModels/ImplementerBindingModel.cs @@ -0,0 +1,13 @@ +using FlowerShopDataModels.Models; + +namespace FlowerShopContracts.BindingModels +{ + public class ImplementerBindingModel : IImplementerModel + { + public int Id { get; set; } + public string ImplementerFIO { get; set; } = string.Empty; + public string Password { get; set; } = string.Empty; + public int WorkExperience { get; set; } + public int Qualification { get; set; } + } +} diff --git a/FlowerShop/FlowerShopContracts/BindingModels/OrderBindingModel.cs b/FlowerShop/FlowerShopContracts/BindingModels/OrderBindingModel.cs index 6888013..83ced06 100644 --- a/FlowerShop/FlowerShopContracts/BindingModels/OrderBindingModel.cs +++ b/FlowerShop/FlowerShopContracts/BindingModels/OrderBindingModel.cs @@ -8,7 +8,8 @@ namespace FlowerShopContracts.BindingModels public int Id { get; set; } public int FlowerId { get; set; } public int ClientId { get; set; } - public int Count { get; set; } + public int ImplementerId { get; set; } = 0; + public int Count { get; set; } public double Sum { get; set; } public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; public DateTime DateCreate { get; set; } = DateTime.Now; diff --git a/FlowerShop/FlowerShopContracts/BusinessLogicsContracts/IImplementerLogic.cs b/FlowerShop/FlowerShopContracts/BusinessLogicsContracts/IImplementerLogic.cs new file mode 100644 index 0000000..fe3b9ba --- /dev/null +++ b/FlowerShop/FlowerShopContracts/BusinessLogicsContracts/IImplementerLogic.cs @@ -0,0 +1,15 @@ +using FlowerShopContracts.BindingModels; +using FlowerShopContracts.SearchModels; +using FlowerShopContracts.ViewModels; + +namespace FlowerShopContracts.BusinessLogicsContracts +{ + public interface IImplementerLogic + { + List? ReadList(ImplementerSearchModel? model); + ImplementerViewModel? ReadElement(ImplementerSearchModel model); + bool Create(ImplementerBindingModel model); + bool Update(ImplementerBindingModel model); + bool Delete(ImplementerBindingModel model); + } +} diff --git a/FlowerShop/FlowerShopContracts/SearchModels/ImplementerSearchModel.cs b/FlowerShop/FlowerShopContracts/SearchModels/ImplementerSearchModel.cs new file mode 100644 index 0000000..4c14254 --- /dev/null +++ b/FlowerShop/FlowerShopContracts/SearchModels/ImplementerSearchModel.cs @@ -0,0 +1,8 @@ +namespace FlowerShopContracts.SearchModels +{ + public class ImplementerSearchModel + { + public int? Id { get; set; } + public string? ImplementerFIO { get; set; } + } +} diff --git a/FlowerShop/FlowerShopContracts/SearchModels/OrderSearchModel.cs b/FlowerShop/FlowerShopContracts/SearchModels/OrderSearchModel.cs index b4a01e5..49b04da 100644 --- a/FlowerShop/FlowerShopContracts/SearchModels/OrderSearchModel.cs +++ b/FlowerShop/FlowerShopContracts/SearchModels/OrderSearchModel.cs @@ -1,10 +1,14 @@ -namespace FlowerShopContracts.SearchModels +using FlowerShopDataModels.Enums; + +namespace FlowerShopContracts.SearchModels { public class OrderSearchModel { public int? Id { get; set; } public int? ClientId { get; set; } + public int? ImplementerId { get; set; } public DateTime? DateFrom { get; set; } public DateTime? DateTo { get; set; } + public OrderStatus Status { get; set; } } } diff --git a/FlowerShop/FlowerShopContracts/StoragesContracts/IImplementerStorage.cs b/FlowerShop/FlowerShopContracts/StoragesContracts/IImplementerStorage.cs new file mode 100644 index 0000000..23f4e4a --- /dev/null +++ b/FlowerShop/FlowerShopContracts/StoragesContracts/IImplementerStorage.cs @@ -0,0 +1,16 @@ +using FlowerShopContracts.BindingModels; +using FlowerShopContracts.SearchModels; +using FlowerShopContracts.ViewModels; + +namespace FlowerShopContracts.StoragesContracts +{ + public interface IImplementerStorage + { + List GetFullList(); + List GetFilteredList(ImplementerSearchModel model); + ImplementerViewModel? GetElement(ImplementerSearchModel model); + ImplementerViewModel? Insert(ImplementerBindingModel model); + ImplementerViewModel? Update(ImplementerBindingModel model); + ImplementerViewModel? Delete(ImplementerBindingModel model); + } +} diff --git a/FlowerShop/FlowerShopContracts/ViewModels/ImplementerViewModel.cs b/FlowerShop/FlowerShopContracts/ViewModels/ImplementerViewModel.cs new file mode 100644 index 0000000..c798605 --- /dev/null +++ b/FlowerShop/FlowerShopContracts/ViewModels/ImplementerViewModel.cs @@ -0,0 +1,18 @@ +using FlowerShopDataModels.Models; +using System.ComponentModel; + +namespace FlowerShopContracts.ViewModels +{ + public class ImplementerViewModel : IImplementerModel + { + public int Id { get; set; } + [DisplayName("ФИО исполнителя")] + public string ImplementerFIO { get; set; } = string.Empty; + [DisplayName("Пароль")] + public string Password { get; set; } = string.Empty; + [DisplayName("Опыт исполнителя")] + public int WorkExperience { get; set; } + [DisplayName("Квалификация исполнителя")] + public int Qualification { get; set; } + } +} diff --git a/FlowerShop/FlowerShopContracts/ViewModels/OrderViewModel.cs b/FlowerShop/FlowerShopContracts/ViewModels/OrderViewModel.cs index a70d495..9fd1640 100644 --- a/FlowerShop/FlowerShopContracts/ViewModels/OrderViewModel.cs +++ b/FlowerShop/FlowerShopContracts/ViewModels/OrderViewModel.cs @@ -10,12 +10,15 @@ namespace FlowerShopContracts.ViewModels public int Id { get; set; } public int FlowerId { get; set; } public int ClientId { get; set; } + public int ImplementerId { get; set; } = 0; [DisplayName("Изделие")] public string FlowerName { get; set; } = string.Empty; [DisplayName("ФИО клиента")] public string ClientFIO { get; set; } = string.Empty; - [DisplayName("Количество")] - public int Count { get; set; } + [DisplayName("ФИО исполнителя")] + public string ImplementerFIO { get; set; }=string.Empty; + [DisplayName("Количество")] + public int Count { get; set; } [DisplayName("Сумма")] public double Sum { get; set; } [DisplayName("Статус")] diff --git a/FlowerShop/FlowerShopDataModels/Models/IImplementerModel.cs b/FlowerShop/FlowerShopDataModels/Models/IImplementerModel.cs new file mode 100644 index 0000000..dc0a61c --- /dev/null +++ b/FlowerShop/FlowerShopDataModels/Models/IImplementerModel.cs @@ -0,0 +1,11 @@ +namespace FlowerShopDataModels.Models +{ + public interface IImplementerModel : IId + { + string ImplementerFIO { get; } + string Password { get; } + int WorkExperience { get; } + int Qualification { get; } + } + +} diff --git a/FlowerShop/FlowerShopDataModels/Models/IOrderModel.cs b/FlowerShop/FlowerShopDataModels/Models/IOrderModel.cs index aa308a9..35fc0f6 100644 --- a/FlowerShop/FlowerShopDataModels/Models/IOrderModel.cs +++ b/FlowerShop/FlowerShopDataModels/Models/IOrderModel.cs @@ -6,6 +6,7 @@ namespace FlowerShopDataModels.Models { int FlowerId { get; } int ClientId { get; } + int ImplementerId { get; } int Count { get; } double Sum { get; } OrderStatus Status { get; } diff --git a/FlowerShop/FlowerShopListImplement/DataListSingleton.cs b/FlowerShop/FlowerShopListImplement/DataListSingleton.cs index 4537e21..a1a6cb6 100644 --- a/FlowerShop/FlowerShopListImplement/DataListSingleton.cs +++ b/FlowerShop/FlowerShopListImplement/DataListSingleton.cs @@ -9,12 +9,14 @@ namespace FlowerShopListImplement public List Orders { get; set; } public List Flowers { get; set; } public List Clients { get; set; } + public List Implementers { get; set; } private DataListSingleton() { Components = new List(); Orders = new List(); Flowers = new List(); Clients = new List(); + Implementers = new List(); } public static DataListSingleton GetInstance() { diff --git a/FlowerShop/FlowerShopListImplement/Implements/OrderStorage.cs b/FlowerShop/FlowerShopListImplement/Implements/OrderStorage.cs index 7e1abb6..f6d0d0a 100644 --- a/FlowerShop/FlowerShopListImplement/Implements/OrderStorage.cs +++ b/FlowerShop/FlowerShopListImplement/Implements/OrderStorage.cs @@ -40,6 +40,17 @@ namespace FlowerShopListImplement.Implements } return result; } + else if (model.ImplementerId.HasValue) + { + foreach (var order in _source.Orders) + { + if (order.Id == model.Id && order.ImplementerId == model.ImplementerId) + { + result.Add(AttachNames(order.GetViewModel)); + } + } + return result; + } foreach (var order in _source.Orders) { if (order.Id == model.Id && order.DateCreate >= model.DateFrom && order.DateCreate <= model.DateTo) @@ -125,7 +136,15 @@ namespace FlowerShopListImplement.Implements return model; } } - return model; + foreach (var implementer in _source.Implementers) + { + if (implementer.Id == model.ImplementerId) + { + model.ImplementerFIO = implementer.ImplementerFIO; + return model; + } + } + return model; } } } diff --git a/FlowerShop/FlowerShopListImplement/Models/Implementer.cs b/FlowerShop/FlowerShopListImplement/Models/Implementer.cs new file mode 100644 index 0000000..25e8d9c --- /dev/null +++ b/FlowerShop/FlowerShopListImplement/Models/Implementer.cs @@ -0,0 +1,49 @@ +using FlowerShopContracts.BindingModels; +using FlowerShopContracts.ViewModels; +using FlowerShopDataModels.Models; + +namespace FlowerShopListImplement.Models +{ + public class Implementer : IImplementerModel + { + public int Id { get; private set; } + public string ImplementerFIO { get; private set; } + public string Password { get; private set; } + public int WorkExperience { get; private set; } + public int Qualification { get; private set; } + public static Implementer? Create(ImplementerBindingModel? model) + { + if (model == null) + { + return null; + } + return new Implementer() + { + Id = model.Id, + ImplementerFIO = model.ImplementerFIO, + Password = model.Password, + WorkExperience = model.WorkExperience, + Qualification = model.Qualification, + }; + } + public void Update(ImplementerBindingModel? model) + { + if (model == null) + { + return; + } + ImplementerFIO = model.ImplementerFIO; + Password = model.Password; + WorkExperience = model.WorkExperience; + Qualification = model.Qualification; + } + public ImplementerViewModel GetViewModel => new() + { + Id = Id, + ImplementerFIO = ImplementerFIO, + Password = Password, + WorkExperience = WorkExperience, + Qualification = Qualification, + }; + } +} diff --git a/FlowerShop/FlowerShopListImplement/Models/Order.cs b/FlowerShop/FlowerShopListImplement/Models/Order.cs index cff9cf2..9c26708 100644 --- a/FlowerShop/FlowerShopListImplement/Models/Order.cs +++ b/FlowerShop/FlowerShopListImplement/Models/Order.cs @@ -10,6 +10,7 @@ namespace FlowerShopListImplement.Models public int Id { get; private set; } public int FlowerId { get; private set; } public int ClientId { get; private set; } + public int ImplementerId { get; private set; } public int Count { get; set; } public double Sum { get; private set; } public OrderStatus Status { get; set; } @@ -26,6 +27,7 @@ namespace FlowerShopListImplement.Models Id = model.Id, FlowerId = model.FlowerId, ClientId = model.ClientId, + ImplementerId = model.ImplementerId, Count = model.Count, Sum = model.Sum, Status = model.Status, @@ -42,6 +44,7 @@ namespace FlowerShopListImplement.Models Id = model.Id; FlowerId = model.FlowerId; ClientId = model.ClientId; + ImplementerId = model.ImplementerId; Count = model.Count; Sum = model.Sum; Status = model.Status; @@ -53,6 +56,7 @@ namespace FlowerShopListImplement.Models Id = Id, FlowerId = FlowerId, ClientId = ClientId, + ImplementerId = ImplementerId, Count = Count, Sum = Sum, Status = Status,