diff --git a/RenovationWork/RenovationWork.sln b/RenovationWork/RenovationWork.sln index 4aeae29..9f55ce3 100644 --- a/RenovationWork/RenovationWork.sln +++ b/RenovationWork/RenovationWork.sln @@ -13,7 +13,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RenovationWorkBusinessLogic EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RenovationWorkListImplement", "RenovationWorkListImplement\RenovationWorkListImplement.csproj", "{CBEF7964-AEB9-4FE9-B85F-9FBDEE198EED}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RenovationWorkFileImplement", "RenovationWorkFileImplement\RenovationWorkFileImplement.csproj", "{C52182B7-2CA7-4D36-BC9F-81F165A4539A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RenovationWorkFileImplement", "RenovationWorkFileImplement\RenovationWorkFileImplement.csproj", "{C52182B7-2CA7-4D36-BC9F-81F165A4539A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RenovationWorkDatabaseImplement", "RenovationWorkDatabaseImplement\RenovationWorkDatabaseImplement.csproj", "{2BB32959-A1A6-4C2B-8C9F-68EA6D60C1EC}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -45,6 +47,10 @@ Global {C52182B7-2CA7-4D36-BC9F-81F165A4539A}.Debug|Any CPU.Build.0 = Debug|Any CPU {C52182B7-2CA7-4D36-BC9F-81F165A4539A}.Release|Any CPU.ActiveCfg = Release|Any CPU {C52182B7-2CA7-4D36-BC9F-81F165A4539A}.Release|Any CPU.Build.0 = Release|Any CPU + {2BB32959-A1A6-4C2B-8C9F-68EA6D60C1EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2BB32959-A1A6-4C2B-8C9F-68EA6D60C1EC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2BB32959-A1A6-4C2B-8C9F-68EA6D60C1EC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2BB32959-A1A6-4C2B-8C9F-68EA6D60C1EC}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/RenovationWork/RenovationWorkDatabaseImplement/Models/Component.cs b/RenovationWork/RenovationWorkDatabaseImplement/Models/Component.cs new file mode 100644 index 0000000..44a53e0 --- /dev/null +++ b/RenovationWork/RenovationWorkDatabaseImplement/Models/Component.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using RenovationWorkContracts.BindingModels; +using RenovationWorkContracts.ViewModels; +using RenovationWorkDataModels.Models; + +namespace RenovationWorkDatabaseImplement.Models +{ + public class Component : IComponentModel + { + public int Id { get; private set; } + [Required] + public string ComponentName { get; private set; } = string.Empty; + [Required] + public double Cost { get; set; } + [ForeignKey("ComponentId")] + public virtual List ProductComponents { get; set; } = new(); + public static Component? Create(ComponentBindingModel model) + { + if (model == null) + { + return null; + } + return new Component() + { + Id = model.Id, + ComponentName = model.ComponentName, + Cost = model.Cost + }; + } + public static Component Create(ComponentViewModel model) + { + return new Component + { + Id = model.Id, + ComponentName = model.ComponentName, + Cost = model.Cost + }; + } + public void Update(ComponentBindingModel model) + { + if (model == null) + { + return; + } + ComponentName = model.ComponentName; + Cost = model.Cost; + } + public ComponentViewModel GetViewModel => new() + { + Id = Id, + ComponentName = ComponentName, + Cost = Cost + }; + + } +} diff --git a/RenovationWork/RenovationWorkDatabaseImplement/Models/Order.cs b/RenovationWork/RenovationWorkDatabaseImplement/Models/Order.cs new file mode 100644 index 0000000..14ad066 --- /dev/null +++ b/RenovationWork/RenovationWorkDatabaseImplement/Models/Order.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using RenovationWorkContracts.BindingModels; +using RenovationWorkContracts.ViewModels; +using RenovationWorkDataModels.Enums; +using RenovationWorkDataModels.Models; + +namespace RenovationWorkDatabaseImplement.Models +{ + public class Order : IOrderModel + { + public int Id { get; private set; } + + public int RepairId { get; private set; } + + public int Count { get; private set; } + + public double Sum { get; private set; } + + public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; + + public DateTime DateCreate { get; set; } = DateTime.Now; + + public DateTime? DateImplement { get; set; } + + public static Order? Create(OrderBindingModel? model) + { + if (model == null) + { + return null; + } + return new Order() + { + Id = model.Id, + RepairId = model.RepairId, + Count = model.Count, + Sum = model.Sum, + Status = model.Status, + DateCreate = model.DateCreate, + DateImplement = model.DateImplement + }; + } + public void Update(OrderBindingModel? model) + { + if (model == null) + { + return; + } + Status = model.Status; + if (model.DateImplement != null) + { + DateImplement = model.DateImplement; + } + } + public OrderViewModel GetViewModel => new() + { + Id = Id, + RepairId = RepairId, + Count = Count, + Sum = Sum, + Status = Status, + DateCreate = DateCreate, + DateImplement = DateImplement + }; + } +} + diff --git a/RenovationWork/RenovationWorkDatabaseImplement/Models/Repair.cs b/RenovationWork/RenovationWorkDatabaseImplement/Models/Repair.cs new file mode 100644 index 0000000..e2ee449 --- /dev/null +++ b/RenovationWork/RenovationWorkDatabaseImplement/Models/Repair.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using RenovationWorkContracts.BindingModels; +using RenovationWorkContracts.ViewModels; +using RenovationWorkDataModels.Models; + +namespace RenovationWorkDatabaseImplement.Models +{ + public class Repair : IRepairModel + { + public int Id { get; private set; } + public string RepairName { get; private set; } = string.Empty; + public double Price { get; private set; } + public Dictionary RepairComponents + { + get; + private set; + } = new Dictionary(); + public static Repair? Create(RepairBindingModel? model) + { + if (model == null) + { + return null; + } + return new Repair() + { + Id = model.Id, + RepairName = model.RepairName, + Price = model.Price, + RepairComponents = model.RepairComponents + }; + } + public void Update(RepairBindingModel? model) + { + if (model == null) + { + return; + } + RepairName = model.RepairName; + Price = model.Price; + RepairComponents = model.RepairComponents; + } + public RepairViewModel GetViewModel => new() + { + Id = Id, + RepairName = RepairName, + Price = Price, + RepairComponents = RepairComponents + }; + } +} diff --git a/RenovationWork/RenovationWorkDatabaseImplement/RenovationWorkDatabaseImplement.csproj b/RenovationWork/RenovationWorkDatabaseImplement/RenovationWorkDatabaseImplement.csproj new file mode 100644 index 0000000..4cb968c --- /dev/null +++ b/RenovationWork/RenovationWorkDatabaseImplement/RenovationWorkDatabaseImplement.csproj @@ -0,0 +1,27 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + +