diff --git a/DressAtelierBusinessLogic/BusinessLogic/DressLogic.cs b/DressAtelierBusinessLogic/BusinessLogic/DressLogic.cs new file mode 100644 index 0000000..16776b1 --- /dev/null +++ b/DressAtelierBusinessLogic/BusinessLogic/DressLogic.cs @@ -0,0 +1,127 @@ +using DressAtelierContracts.BindingModels; +using DressAtelierContracts.BusinessLogicContracts; +using DressAtelierContracts.SearchModels; +using DressAtelierContracts.StorageContracts; +using DressAtelierContracts.ViewModels; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DressAtelierBusinessLogic.BusinessLogic +{ + public class DressLogic : IDressLogic + { + private readonly ILogger _logger; + + private readonly IDressStorage _productStorage; + + public DressLogic(ILogger logger, IDressStorage productStorage) + { + _logger = logger; + _productStorage = productStorage; + } + public bool Create(DressBindingModel model) + { + CheckModel(model); + if(_productStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + + public bool Update(DressBindingModel model) + { + CheckModel(model); + if (_productStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + + public bool Delete(DressBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. ID:{ID}", model.ID); + if (_productStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + + public DressViewModel? ReadElement(DressSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + _logger.LogInformation("ReadElement. ProductName:{ProductName}.ID:{ ID}", model.ProductName, model.ID); + + var element = _productStorage.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(DressSearchModel? model) + { + _logger.LogInformation("ReadList. ProductName:{ProductName}. ID:{ ID}", model?.ProductName, model?.ID); + + var list = model == null ? _productStorage.GetFullList() : _productStorage.GetFilteredList(model); + + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + + private void CheckModel(DressBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.ProductName)) + { + throw new ArgumentNullException("Invalid name of product",nameof(model.ProductName)); + } + if (model.Price <= 0) + { + throw new ArgumentNullException("Price of product should be higher than 0", nameof(model.Price)); + } + _logger.LogInformation("Product. ProductName:{ProductName}. Cost:{Cost}. ID: {ID}", model.ProductName, model.Price, model.ID); + + var element = _productStorage.GetElement(new DressSearchModel + { + ProductName = model.ProductName, + }); + + if (element != null && element.ID != model.ID) + { + throw new InvalidOperationException("Product with such name already exists"); + } + } + } +} diff --git a/DressAtelierBusinessLogic/BusinessLogic/MaterialComponentsLogic.cs b/DressAtelierBusinessLogic/BusinessLogic/MaterialComponentsLogic.cs new file mode 100644 index 0000000..ad49c3c --- /dev/null +++ b/DressAtelierBusinessLogic/BusinessLogic/MaterialComponentsLogic.cs @@ -0,0 +1,131 @@ +using DressAtelierContracts.BindingModels; +using DressAtelierContracts.BusinessLogicContracts; +using DressAtelierContracts.SearchModels; +using DressAtelierContracts.StorageContracts; +using DressAtelierContracts.ViewModels; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DressAtelierBusinessLogic.BusinessLogic +{ + public class MaterialComponentsLogic : IMaterialLogic + { + private readonly ILogger _logger; + + private readonly IMaterialStorage _componentStorage; + public MaterialComponentsLogic(ILogger logger, IMaterialStorage componentStorage) + { + _logger = logger; + _componentStorage = componentStorage; + } + + public bool Create(MaterialBindingModel model) + { + CheckModel(model); + if (_componentStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + + public bool Update(MaterialBindingModel model) + { + CheckModel(model); + if (_componentStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + + } + + public bool Delete(MaterialBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. ID:{ID}", model.ID); + if (_componentStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + + } + + public MaterialViewModel? ReadElement(MaterialSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + _logger.LogInformation("ReadElement. ComponentName:{ComponentName}.ID:{ ID}", model.ComponentName, model.ID); + + var element = _componentStorage.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(MaterialSearchModel? model) + { + _logger.LogInformation("ReadList. ComponentName:{ComponentName}. ID:{ ID}", model?.ComponentName, model?.ID); + + var list = model == null ? _componentStorage.GetFullList() : _componentStorage.GetFilteredList(model); + + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + + } + + private void CheckModel(MaterialBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.ComponentName)) + { + throw new ArgumentNullException("Invalid name of component", nameof(model.ComponentName)); + } + if (model.Cost <= 0) + { + throw new ArgumentNullException("Price of component should be higher than 0", nameof(model.Cost)); + } + _logger.LogInformation("Component. ComponentName:{ComponentName}. Cost:{ Cost}. ID: { ID} ", model.ComponentName, model.Cost, model.ID); + + var element = _componentStorage.GetElement(new MaterialSearchModel + { + ComponentName = model.ComponentName + }); + + if (element != null && element.ID != model.ID) + { + throw new InvalidOperationException("Component with such name already exists."); + } + } + + } +} diff --git a/DressAtelierBusinessLogic/BusinessLogic/OrderLogic.cs b/DressAtelierBusinessLogic/BusinessLogic/OrderLogic.cs new file mode 100644 index 0000000..aff3202 --- /dev/null +++ b/DressAtelierBusinessLogic/BusinessLogic/OrderLogic.cs @@ -0,0 +1,122 @@ +using DressAtelierContracts.BindingModels; +using DressAtelierContracts.BusinessLogicContracts; +using DressAtelierContracts.SearchModels; +using DressAtelierContracts.StorageContracts; +using DressAtelierContracts.ViewModels; +using DressAtelierDataModels.Enums; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DressAtelierBusinessLogic.BusinessLogic +{ + public class OrderLogic : IOrderLogic + { + private readonly ILogger _logger; + + private readonly IOrderStorage _orderStorage; + + public OrderLogic(ILogger logger, IOrderStorage orderStorage) + { + _logger = logger; + _orderStorage = orderStorage; + } + + public bool CreateOrder(OrderBindingModel model) + { + CheckModel(model); + + if (model.Status != OrderStatus.Unknown) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + + model.Status = OrderStatus.Accepted; + if (_orderStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + + public bool GivenOrder(OrderBindingModel model) + { + CheckModel(model); + _logger.LogInformation("Update to given status. ID:{ID}", model.ID); + if (_orderStorage.Update(model) == null || model.Status == OrderStatus.Ready) + { + _logger.LogWarning("Update operation failed"); + return false; + } + model.Status = OrderStatus.Given; + + return true; + } + + public bool ReadyOrder(OrderBindingModel model) + { + CheckModel(model); + _logger.LogInformation("Update to ready status. ID:{ID}", model.ID); + if (_orderStorage.Update(model) == null || model.Status == OrderStatus.InProcess) + { + _logger.LogWarning("Update operation failed"); + return false; + } + model.Status = OrderStatus.Ready; + model.DateImplement = DateTime.Now; + return true; + } + + public bool TakeOrderInWork(OrderBindingModel model) + { + CheckModel(model); + _logger.LogInformation("Update to ready status. ID:{ID}", model.ID); + if (_orderStorage.Update(model) == null || model.Status == OrderStatus.Accepted) + { + _logger.LogWarning("Update operation failed"); + return false; + } + model.Status = OrderStatus.InProcess; + return true; + } + + public List? ReadList(OrderSearchModel? model) + { + _logger.LogInformation("ReadList. OrderID:{ID}",model.ID); + + var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model); + + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + + public void CheckModel(OrderBindingModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("Order. OrderID: { ID} ",model.ID); + + var element = _orderStorage.GetElement(new OrderSearchModel + { + ID = model.ID + }); + + if (element == null) + { + throw new InvalidOperationException("Order with such name already exists."); + } + } + } +} diff --git a/DressAtelierBusinessLogic/DressAtelierBusinessLogic.csproj b/DressAtelierBusinessLogic/DressAtelierBusinessLogic.csproj new file mode 100644 index 0000000..358a51c --- /dev/null +++ b/DressAtelierBusinessLogic/DressAtelierBusinessLogic.csproj @@ -0,0 +1,17 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + diff --git a/DressAtelierContracts/BindingModels/DressBindingModel.cs b/DressAtelierContracts/BindingModels/DressBindingModel.cs new file mode 100644 index 0000000..7a52b31 --- /dev/null +++ b/DressAtelierContracts/BindingModels/DressBindingModel.cs @@ -0,0 +1,20 @@ +using DressAtelierDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DressAtelierContracts.BindingModels +{ + public class DressBindingModel : IDressModel + { + public int ID { get; set; } + public string ProductName { get; set; } = string.Empty; + + public double Price { get; set; } + + public Dictionary ProductComponents { get; set; } = new(); + + } +} diff --git a/DressAtelierContracts/BindingModels/MaterialBindingModel.cs b/DressAtelierContracts/BindingModels/MaterialBindingModel.cs new file mode 100644 index 0000000..955a397 --- /dev/null +++ b/DressAtelierContracts/BindingModels/MaterialBindingModel.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DressAtelierDataModels.Models; + +namespace DressAtelierContracts.BindingModels +{ + public class MaterialBindingModel : IMaterialModel + { + public int ID { get; set; } + + public string ComponentName { get; set; } = string.Empty; + + public double Cost { get; set; } + } +} diff --git a/DressAtelierContracts/BindingModels/OrderBindingModel.cs b/DressAtelierContracts/BindingModels/OrderBindingModel.cs new file mode 100644 index 0000000..83eb542 --- /dev/null +++ b/DressAtelierContracts/BindingModels/OrderBindingModel.cs @@ -0,0 +1,27 @@ +using DressAtelierDataModels.Enums; +using DressAtelierDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DressAtelierContracts.BindingModels +{ + public class OrderBindingModel : IOrderModel + { + public int ProductID { get; set; } + + public int Count { get; set; } + + public double Sum { get; set; } + + public OrderStatus Status { get; set; } = OrderStatus.Unknown; + + public DateTime DateCreate { get; set; } = DateTime.Now; + + public DateTime? DateImplement { get; set; } + + public int ID { get; set; } + } +} diff --git a/DressAtelierContracts/BusinessLogicContracts/IDressLogic.cs b/DressAtelierContracts/BusinessLogicContracts/IDressLogic.cs new file mode 100644 index 0000000..aaffedc --- /dev/null +++ b/DressAtelierContracts/BusinessLogicContracts/IDressLogic.cs @@ -0,0 +1,21 @@ +using DressAtelierContracts.BindingModels; +using DressAtelierContracts.SearchModels; +using DressAtelierContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DressAtelierContracts.BusinessLogicContracts +{ + public interface IDressLogic + { + List? ReadList(DressSearchModel? model); + DressViewModel? ReadElement(DressSearchModel model); + + bool Create(DressBindingModel model); + bool Update(DressBindingModel model); + bool Delete(DressBindingModel model); + } +} diff --git a/DressAtelierContracts/BusinessLogicContracts/IMaterialLogic.cs b/DressAtelierContracts/BusinessLogicContracts/IMaterialLogic.cs new file mode 100644 index 0000000..2aa2c1a --- /dev/null +++ b/DressAtelierContracts/BusinessLogicContracts/IMaterialLogic.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DressAtelierContracts.BindingModels; +using DressAtelierContracts.SearchModels; +using DressAtelierContracts.ViewModels; + +namespace DressAtelierContracts.BusinessLogicContracts +{ + public interface IMaterialLogic + { + List? ReadList(MaterialSearchModel? model); + + MaterialViewModel? ReadElement(MaterialSearchModel model); + + bool Create(MaterialBindingModel model); + bool Update(MaterialBindingModel model); + bool Delete(MaterialBindingModel model); + } +} diff --git a/DressAtelierContracts/BusinessLogicContracts/IOrderLogic.cs b/DressAtelierContracts/BusinessLogicContracts/IOrderLogic.cs new file mode 100644 index 0000000..f15e01a --- /dev/null +++ b/DressAtelierContracts/BusinessLogicContracts/IOrderLogic.cs @@ -0,0 +1,21 @@ +using DressAtelierContracts.BindingModels; +using DressAtelierContracts.SearchModels; +using DressAtelierContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DressAtelierContracts.BusinessLogicContracts +{ + public interface IOrderLogic + { + List? ReadList(OrderSearchModel? model); + bool CreateOrder(OrderBindingModel model); + bool TakeOrderInWork(OrderBindingModel model); + bool ReadyOrder(OrderBindingModel model); + bool GivenOrder(OrderBindingModel model); + + } +} diff --git a/DressAtelierContracts/DressAtelierContracts.csproj b/DressAtelierContracts/DressAtelierContracts.csproj new file mode 100644 index 0000000..d7aba36 --- /dev/null +++ b/DressAtelierContracts/DressAtelierContracts.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/DressAtelierContracts/SearchModels/DressSearchModel.cs b/DressAtelierContracts/SearchModels/DressSearchModel.cs new file mode 100644 index 0000000..61a8c46 --- /dev/null +++ b/DressAtelierContracts/SearchModels/DressSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DressAtelierContracts.SearchModels +{ + public class DressSearchModel + { + public int? ID { get; set; } + public string? ProductName { get; set; } + } +} diff --git a/DressAtelierContracts/SearchModels/MaterialSearchModel.cs b/DressAtelierContracts/SearchModels/MaterialSearchModel.cs new file mode 100644 index 0000000..c214544 --- /dev/null +++ b/DressAtelierContracts/SearchModels/MaterialSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DressAtelierContracts.SearchModels +{ + public class MaterialSearchModel + { + public int? ID { get; set; } + public string? ComponentName { get; set; } + } +} diff --git a/DressAtelierContracts/SearchModels/OrderSearchModel.cs b/DressAtelierContracts/SearchModels/OrderSearchModel.cs new file mode 100644 index 0000000..b408259 --- /dev/null +++ b/DressAtelierContracts/SearchModels/OrderSearchModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DressAtelierContracts.SearchModels +{ + public class OrderSearchModel + { + public int? ID { get; set; } + } +} diff --git a/DressAtelierContracts/StorageContracts/IDressStorage.cs b/DressAtelierContracts/StorageContracts/IDressStorage.cs new file mode 100644 index 0000000..94822f7 --- /dev/null +++ b/DressAtelierContracts/StorageContracts/IDressStorage.cs @@ -0,0 +1,21 @@ +using DressAtelierContracts.BindingModels; +using DressAtelierContracts.SearchModels; +using DressAtelierContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DressAtelierContracts.StorageContracts +{ + public interface IDressStorage + { + List GetFullList(); + List GetFilteredList(DressSearchModel model); + DressViewModel? GetElement(DressSearchModel model); + DressViewModel? Insert(DressBindingModel model); + DressViewModel? Delete(DressBindingModel model); + DressViewModel? Update(DressBindingModel model); + } +} diff --git a/DressAtelierContracts/StorageContracts/IMaterialStorage.cs b/DressAtelierContracts/StorageContracts/IMaterialStorage.cs new file mode 100644 index 0000000..285c83a --- /dev/null +++ b/DressAtelierContracts/StorageContracts/IMaterialStorage.cs @@ -0,0 +1,21 @@ +using DressAtelierContracts.ViewModels; +using DressAtelierContracts.BindingModels; +using DressAtelierContracts.SearchModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DressAtelierContracts.StorageContracts +{ + public interface IMaterialStorage + { + List GetFullList(); + List GetFilteredList(MaterialSearchModel model); + MaterialViewModel? GetElement(MaterialSearchModel model); + MaterialViewModel? Insert(MaterialBindingModel model); + MaterialViewModel? Update(MaterialBindingModel model); + MaterialViewModel? Delete(MaterialBindingModel model); + } +} diff --git a/DressAtelierContracts/StorageContracts/IOrderStorage.cs b/DressAtelierContracts/StorageContracts/IOrderStorage.cs new file mode 100644 index 0000000..9b46087 --- /dev/null +++ b/DressAtelierContracts/StorageContracts/IOrderStorage.cs @@ -0,0 +1,22 @@ +using DressAtelierContracts.BindingModels; +using DressAtelierContracts.SearchModels; +using DressAtelierContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DressAtelierContracts.StorageContracts +{ + public interface IOrderStorage + { + List? GetFullList(); + List GetFilteredList(OrderSearchModel model); + OrderViewModel? GetElement(OrderSearchModel model); + OrderViewModel? Insert(OrderBindingModel model); + OrderViewModel? Delete(OrderBindingModel model); + OrderViewModel? Update(OrderBindingModel model); + + } +} diff --git a/DressAtelierContracts/ViewModels/DressViewModel.cs b/DressAtelierContracts/ViewModels/DressViewModel.cs new file mode 100644 index 0000000..75f30af --- /dev/null +++ b/DressAtelierContracts/ViewModels/DressViewModel.cs @@ -0,0 +1,23 @@ +using DressAtelierDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DressAtelierContracts.ViewModels +{ + public class DressViewModel : IDressModel + { + [DisplayName("Name of product")] + public string ProductName { get; set; } = string.Empty; + + [DisplayName("Cost")] + public double Price { get; set; } + + public Dictionary ProductComponents { get; set; } = new(); + + public int ID { get; set; } + } +} diff --git a/DressAtelierContracts/ViewModels/MaterialViewModel.cs b/DressAtelierContracts/ViewModels/MaterialViewModel.cs new file mode 100644 index 0000000..8b3ced6 --- /dev/null +++ b/DressAtelierContracts/ViewModels/MaterialViewModel.cs @@ -0,0 +1,20 @@ +using DressAtelierDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.ComponentModel; +namespace DressAtelierContracts.ViewModels +{ + public class MaterialViewModel : IMaterialModel + { + [DisplayName("Name of component")] + public string ComponentName { get; set; } = string.Empty; + + [DisplayName("Cost")] + public double Cost { get; set; } + + public int ID { get; set; } + } +} diff --git a/DressAtelierContracts/ViewModels/OrderViewModel.cs b/DressAtelierContracts/ViewModels/OrderViewModel.cs new file mode 100644 index 0000000..52d2534 --- /dev/null +++ b/DressAtelierContracts/ViewModels/OrderViewModel.cs @@ -0,0 +1,34 @@ +using DressAtelierDataModels.Enums; +using DressAtelierDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DressAtelierContracts.ViewModels +{ + public class OrderViewModel : IOrderModel + { + public int ProductID { get; set; } + + [DisplayName("Quantity")] + public int Count { get; set; } + + [DisplayName("Overall price")] + public double Sum { get; set; } + + [DisplayName("Status")] + public OrderStatus Status { get; set; } = OrderStatus.Unknown; + + [DisplayName("Date of creation")] + public DateTime DateCreate { get; set; } = DateTime.Now; + + [DisplayName("Date of implementation")] + public DateTime? DateImplement { get; set; } + + [DisplayName("ID")] + public int ID { get; set; } + } +} diff --git a/DressAtelierDataModels/DressAtelierDataModels.csproj b/DressAtelierDataModels/DressAtelierDataModels.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/DressAtelierDataModels/DressAtelierDataModels.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/DressAtelierDataModels/Enums/OrderStatus.cs b/DressAtelierDataModels/Enums/OrderStatus.cs new file mode 100644 index 0000000..b0c18d8 --- /dev/null +++ b/DressAtelierDataModels/Enums/OrderStatus.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DressAtelierDataModels.Enums +{ + public enum OrderStatus + { + Unknown = -1, + Accepted = 0, + InProcess = 1, + Ready = 2, + Given = 3 + } +} diff --git a/DressAtelierDataModels/IID.cs b/DressAtelierDataModels/IID.cs new file mode 100644 index 0000000..f946bd0 --- /dev/null +++ b/DressAtelierDataModels/IID.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DressAtelierDataModels +{ + public interface IID + { + int ID { get; } + } +} diff --git a/DressAtelierDataModels/Models/IDressModel.cs b/DressAtelierDataModels/Models/IDressModel.cs new file mode 100644 index 0000000..b29612e --- /dev/null +++ b/DressAtelierDataModels/Models/IDressModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DressAtelierDataModels.Models +{ + public interface IDressModel : IID + { + string ProductName { get; } + double Price { get; } + Dictionary ProductComponents { get; } + } +} diff --git a/DressAtelierDataModels/Models/IMaterialModel.cs b/DressAtelierDataModels/Models/IMaterialModel.cs new file mode 100644 index 0000000..782f23e --- /dev/null +++ b/DressAtelierDataModels/Models/IMaterialModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DressAtelierDataModels.Models +{ + public interface IMaterialModel : IID + { + string ComponentName { get; } + double Cost { get; } + } +} diff --git a/DressAtelierDataModels/Models/IOrderModel.cs b/DressAtelierDataModels/Models/IOrderModel.cs new file mode 100644 index 0000000..fc03ca0 --- /dev/null +++ b/DressAtelierDataModels/Models/IOrderModel.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DressAtelierDataModels.Enums; + +namespace DressAtelierDataModels.Models +{ + public interface IOrderModel :IID + { + int ProductID { get;} + int Count { get; } + double Sum { get; } + OrderStatus Status { get; } + DateTime DateCreate { get; } + DateTime? DateImplement { get; } + } +} diff --git a/DressAtelierListImplement/DataListSingleton.cs b/DressAtelierListImplement/DataListSingleton.cs new file mode 100644 index 0000000..bb173f7 --- /dev/null +++ b/DressAtelierListImplement/DataListSingleton.cs @@ -0,0 +1,31 @@ +using DressAtelierListImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DressAtelierListImplement +{ + public class DataListSingleton + { + private static DataListSingleton? _instance; + public List Components { get; set; } + public List Orders { get; set; } + public List Products { get; set; } + private DataListSingleton() + { + Components = new List(); + Orders = new List(); + Products = new List(); + } + public static DataListSingleton GetInstance() + { + if (_instance == null) + { + _instance = new DataListSingleton(); + } + return _instance; + } + } +} diff --git a/DressAtelierListImplement/DressAtelierListImplement.csproj b/DressAtelierListImplement/DressAtelierListImplement.csproj new file mode 100644 index 0000000..ded099c --- /dev/null +++ b/DressAtelierListImplement/DressAtelierListImplement.csproj @@ -0,0 +1,14 @@ + + + + net6.0 + enable + enable + + + + + + + + diff --git a/DressAtelierListImplement/Models/Dress.cs b/DressAtelierListImplement/Models/Dress.cs new file mode 100644 index 0000000..3d7ef2b --- /dev/null +++ b/DressAtelierListImplement/Models/Dress.cs @@ -0,0 +1,58 @@ +using DressAtelierContracts.BindingModels; +using DressAtelierContracts.BusinessLogicContracts; +using DressAtelierContracts.SearchModels; +using DressAtelierContracts.ViewModels; +using DressAtelierDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DressAtelierListImplement.Models +{ + public class Dress : IDressModel + { + public int ID { get; private set; } + public string ProductName { get; private set; } = string.Empty; + + public double Price { get; private set; } + + public Dictionary ProductComponents { get; private set; } = new Dictionary(); + + public static Dress? Create(DressBindingModel? model) + { + if (model == null) + { + return null; + } + return new Dress() + { + ID = model.ID, + ProductName = model.ProductName, + Price = model.Price, + ProductComponents = model.ProductComponents + }; + + } + + public void Update(DressBindingModel? model) + { + if (model == null) + { + return; + } + ProductName = model.ProductName; + Price = model.Price; + ProductComponents = model.ProductComponents; + } + public DressViewModel GetViewModel => new() + { + ID = ID, + ProductName = ProductName, + Price = Price, + ProductComponents = ProductComponents + }; + + } +} diff --git a/DressAtelierListImplement/Models/Material.cs b/DressAtelierListImplement/Models/Material.cs new file mode 100644 index 0000000..b7778e7 --- /dev/null +++ b/DressAtelierListImplement/Models/Material.cs @@ -0,0 +1,49 @@ +using DressAtelierContracts.BindingModels; +using DressAtelierContracts.ViewModels; +using DressAtelierDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DressAtelierListImplement.Models +{ + public class Material : IMaterialModel + { + public string ComponentName { get; private set; } = string.Empty; + + public double Cost { get; set; } + + public int ID { get; private set; } + + public static Material? Create(MaterialBindingModel? model) + { + if (model == null) + { + return null; + } + return new Material() + { + ID = model.ID, + ComponentName = model.ComponentName, + Cost = model.Cost + }; + } + public void Update(MaterialBindingModel? model) + { + if (model == null) + { + return; + } + ComponentName = model.ComponentName; + Cost = model.Cost; + } + public MaterialViewModel GetViewModel => new() + { + ID = ID, + ComponentName = ComponentName, + Cost = Cost + }; + } +} diff --git a/DressAtelierListImplement/Models/Order.cs b/DressAtelierListImplement/Models/Order.cs new file mode 100644 index 0000000..77619cf --- /dev/null +++ b/DressAtelierListImplement/Models/Order.cs @@ -0,0 +1,76 @@ +using DressAtelierContracts.BindingModels; +using DressAtelierContracts.ViewModels; +using DressAtelierDataModels.Enums; +using DressAtelierDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace DressAtelierListImplement.Models +{ + public class Order : IOrderModel + { + public int ID { get; private set; } + public int ProductID { get; private set; } + + public int Count {get; private set; } + + public double Sum { get; private set; } + + public OrderStatus Status { get; private set; } = OrderStatus.Unknown; + + public DateTime DateCreate { get; private set; } = DateTime.Now; + + public DateTime? DateImplement { get; private set; } + + public static Order? Create(OrderBindingModel? model) + { + if (model == null) + { + return null; + } + return new Order() + { + ID = model.ID, + ProductID = model.ProductID, + Count = model.Count, + Sum = model.Sum, + Status = model.Status, + DateCreate = model.DateCreate, + DateImplement = model.DateImplement + }; + + } + + public void Update(OrderBindingModel? model) + { + if (model == null) + { + return; + } + + ProductID = model.ProductID; + Count = model.Count; + Sum = model.Sum; + Status = model.Status; + DateCreate = model.DateCreate; + } + + public OrderViewModel GetViewModel => new() + { + ID = ID, + ProductID = ProductID, + Count = Count, + Sum = Sum, + Status = Status, + DateCreate = DateCreate, + DateImplement = DateImplement + + }; + + + } +} diff --git a/SewingDresses/SewingDresses.sln b/SewingDresses/SewingDresses.sln index 5f6e84f..ef6e23b 100644 --- a/SewingDresses/SewingDresses.sln +++ b/SewingDresses/SewingDresses.sln @@ -5,6 +5,14 @@ VisualStudioVersion = 17.3.32825.248 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SewingDresses", "SewingDresses.csproj", "{477532B4-09CB-45E7-9AE5-652CAE3E340C}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DressAtelierDataModels", "..\DressAtelierDataModels\DressAtelierDataModels.csproj", "{2D48D801-8A00-4FFE-B995-8090A65D0A07}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DressAtelierContracts", "..\DressAtelierContracts\DressAtelierContracts.csproj", "{5500343A-5929-4C91-8509-D0E5F65D19BF}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DressAtelierBusinessLogic", "..\DressAtelierBusinessLogic\DressAtelierBusinessLogic.csproj", "{535CDE3E-E0FB-4389-905D-B23C8BA13044}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DressAtelierListImplement", "..\DressAtelierListImplement\DressAtelierListImplement.csproj", "{1A88E277-E50A-45C5-89FA-677EBCD2EF63}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +23,22 @@ Global {477532B4-09CB-45E7-9AE5-652CAE3E340C}.Debug|Any CPU.Build.0 = Debug|Any CPU {477532B4-09CB-45E7-9AE5-652CAE3E340C}.Release|Any CPU.ActiveCfg = Release|Any CPU {477532B4-09CB-45E7-9AE5-652CAE3E340C}.Release|Any CPU.Build.0 = Release|Any CPU + {2D48D801-8A00-4FFE-B995-8090A65D0A07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2D48D801-8A00-4FFE-B995-8090A65D0A07}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2D48D801-8A00-4FFE-B995-8090A65D0A07}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2D48D801-8A00-4FFE-B995-8090A65D0A07}.Release|Any CPU.Build.0 = Release|Any CPU + {5500343A-5929-4C91-8509-D0E5F65D19BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5500343A-5929-4C91-8509-D0E5F65D19BF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5500343A-5929-4C91-8509-D0E5F65D19BF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5500343A-5929-4C91-8509-D0E5F65D19BF}.Release|Any CPU.Build.0 = Release|Any CPU + {535CDE3E-E0FB-4389-905D-B23C8BA13044}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {535CDE3E-E0FB-4389-905D-B23C8BA13044}.Debug|Any CPU.Build.0 = Debug|Any CPU + {535CDE3E-E0FB-4389-905D-B23C8BA13044}.Release|Any CPU.ActiveCfg = Release|Any CPU + {535CDE3E-E0FB-4389-905D-B23C8BA13044}.Release|Any CPU.Build.0 = Release|Any CPU + {1A88E277-E50A-45C5-89FA-677EBCD2EF63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1A88E277-E50A-45C5-89FA-677EBCD2EF63}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1A88E277-E50A-45C5-89FA-677EBCD2EF63}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1A88E277-E50A-45C5-89FA-677EBCD2EF63}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE