From 34fdfcfca35f3208ebd1848badf9541fdfb72ce3 Mon Sep 17 00:00:00 2001 From: FLARJ <122087628+FLARJ@users.noreply.github.com> Date: Thu, 6 Apr 2023 22:37:40 +0400 Subject: [PATCH] fix --- .../BindingModels/HeadsetBindingModel.cs | 3 +- .../BindingModels/ManagerBindingModel.cs | 7 +- .../BindingModels/OrdersBindingModel.cs | 2 +- .../ViewModel/OrdersViewModel.cs | 2 +- FurnitureFactory/FurnitureFactory.sln | 6 + .../FurnitureFactoryDataBaseImplement.csproj | 9 ++ .../Models/HeadsetSalesSalons.cs | 20 +++ .../Models/Manager.cs | 12 ++ .../Models/Orders.cs | 124 ++++++++++++++++++ .../Models/OrdersSalesSalons.cs | 12 ++ .../Models/SalesSalons.cs | 82 ++++++++++++ .../Models/IHeadsetModel.cs | 3 +- .../Models/IOrdersModel.cs | 2 +- .../Models/ISalesSalonsModel.cs | 1 - 14 files changed, 275 insertions(+), 10 deletions(-) create mode 100644 FurnitureFactory/FurnitureFactoryDataBaseImplement/FurnitureFactoryDataBaseImplement.csproj create mode 100644 FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/HeadsetSalesSalons.cs create mode 100644 FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Manager.cs create mode 100644 FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Orders.cs create mode 100644 FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/OrdersSalesSalons.cs create mode 100644 FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/SalesSalons.cs diff --git a/FurnitureFactory/FurnitureContracts/BindingModels/HeadsetBindingModel.cs b/FurnitureFactory/FurnitureContracts/BindingModels/HeadsetBindingModel.cs index 86d3e54..7764f48 100644 --- a/FurnitureFactory/FurnitureContracts/BindingModels/HeadsetBindingModel.cs +++ b/FurnitureFactory/FurnitureContracts/BindingModels/HeadsetBindingModel.cs @@ -8,6 +8,7 @@ namespace FurnitureContracts.BindingModels public int Cost { get; set; } public int Id { get; set; } public int ManagerId { get; set; } - public Dictionary HeadsetModuleId { get; set; } + public int HeadsetModuleId { get; set; } + public Dictionary SalesSalonsId { get; set; } } } diff --git a/FurnitureFactory/FurnitureContracts/BindingModels/ManagerBindingModel.cs b/FurnitureFactory/FurnitureContracts/BindingModels/ManagerBindingModel.cs index b5f76a5..a8a3c1f 100644 --- a/FurnitureFactory/FurnitureContracts/BindingModels/ManagerBindingModel.cs +++ b/FurnitureFactory/FurnitureContracts/BindingModels/ManagerBindingModel.cs @@ -5,10 +5,9 @@ namespace FurnitureContracts.BindingModels public class ManagerBindingModel : IManagerModel { public string UserName { get; set; } = string.Empty; - public string Login { get; } - public string Password { get; } - public string Role { get; } - + public string Login { get; set; } = string.Empty; + public string Password { get; set; } = string.Empty; + public string Role { get; set; } = string.Empty; public int Id { get; set; } } } diff --git a/FurnitureFactory/FurnitureContracts/BindingModels/OrdersBindingModel.cs b/FurnitureFactory/FurnitureContracts/BindingModels/OrdersBindingModel.cs index 2fb2cd4..a938a4e 100644 --- a/FurnitureFactory/FurnitureContracts/BindingModels/OrdersBindingModel.cs +++ b/FurnitureFactory/FurnitureContracts/BindingModels/OrdersBindingModel.cs @@ -8,6 +8,6 @@ namespace FurnitureContracts.BindingModels public string Status { get; set; } = string.Empty; public int Id { get; set; } public int ManagerId { get; set; } - public Dictionary FurnitureId { get; set; } + public Dictionary SalesSalonsId { get; set; } } } diff --git a/FurnitureFactory/FurnitureContracts/ViewModel/OrdersViewModel.cs b/FurnitureFactory/FurnitureContracts/ViewModel/OrdersViewModel.cs index 47e379c..2c9b741 100644 --- a/FurnitureFactory/FurnitureContracts/ViewModel/OrdersViewModel.cs +++ b/FurnitureFactory/FurnitureContracts/ViewModel/OrdersViewModel.cs @@ -17,6 +17,6 @@ namespace FurnitureContracts.ViewModel public string Status { get; set; } = string.Empty; public int Id { get; set; } public int ManagerId { get; set; } - public Dictionary FurnitureId { get; set; } + public Dictionary SalesSalonsId { get; set; } } } diff --git a/FurnitureFactory/FurnitureFactory.sln b/FurnitureFactory/FurnitureFactory.sln index 6103753..472e8f3 100644 --- a/FurnitureFactory/FurnitureFactory.sln +++ b/FurnitureFactory/FurnitureFactory.sln @@ -9,6 +9,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureFactoryDataModels" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureContracts", "FurnitureContracts\FurnitureContracts.csproj", "{E269E4B8-5EAD-4BB2-A8BA-44FE9D202FB6}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FurnitureFactoryDataBaseImplement", "FurnitureFactoryDataBaseImplement\FurnitureFactoryDataBaseImplement.csproj", "{833913DB-1F3F-4700-A200-90759788B1A9}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -27,6 +29,10 @@ Global {E269E4B8-5EAD-4BB2-A8BA-44FE9D202FB6}.Debug|Any CPU.Build.0 = Debug|Any CPU {E269E4B8-5EAD-4BB2-A8BA-44FE9D202FB6}.Release|Any CPU.ActiveCfg = Release|Any CPU {E269E4B8-5EAD-4BB2-A8BA-44FE9D202FB6}.Release|Any CPU.Build.0 = Release|Any CPU + {833913DB-1F3F-4700-A200-90759788B1A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {833913DB-1F3F-4700-A200-90759788B1A9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {833913DB-1F3F-4700-A200-90759788B1A9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {833913DB-1F3F-4700-A200-90759788B1A9}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/FurnitureFactory/FurnitureFactoryDataBaseImplement/FurnitureFactoryDataBaseImplement.csproj b/FurnitureFactory/FurnitureFactoryDataBaseImplement/FurnitureFactoryDataBaseImplement.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/FurnitureFactory/FurnitureFactoryDataBaseImplement/FurnitureFactoryDataBaseImplement.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/HeadsetSalesSalons.cs b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/HeadsetSalesSalons.cs new file mode 100644 index 0000000..4f7ba58 --- /dev/null +++ b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/HeadsetSalesSalons.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureFactoryDataBaseImplement.Models +{ + internal class HeadsetSalesSalons + { + public int Id { get; set; } + [Required] + public int HeadsetId { get; set; } + [Required] + public int SalesSalonsId { get; set; } + public virtual Headset Headset { get; set; } = new(); + public virtual SalesSalons SalesSalons { get; set; } = new(); + } +} diff --git a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Manager.cs b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Manager.cs new file mode 100644 index 0000000..ea19f48 --- /dev/null +++ b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Manager.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureFactoryDataBaseImplement.Models +{ + internal class Manager + { + } +} diff --git a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Orders.cs b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Orders.cs new file mode 100644 index 0000000..390d2f5 --- /dev/null +++ b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Orders.cs @@ -0,0 +1,124 @@ +//using System; +//using System.Collections.Generic; +//using System.Linq; +//using System.Text; +//using System.Threading.Tasks; +//using FurnitureContracts.BindingModels; +//using FurnitureContracts.ViewModel; +//using FurnitureFactoryDataModels.Models; +//using System; +//using System.Collections.Generic; +//using System.ComponentModel.DataAnnotations; +//using System.ComponentModel.DataAnnotations.Schema; + +//namespace FurnitureFactoryDataBaseImplement.Models +//{ +// internal class Orders : IOrders +// { +// // мое +// //DateTime Date { get; } +// //string Status { get; } +// //public Dictionary FurnitureId { get; } +// //int ManagerId { get; } + + + +// string Title { get; } +// string Description { get; } +// string? TaskName { get; } +// DateTime DateCreate { get; } +// int TaskId { get; } +// int StudentId { get; } +// string StudentName { get; } +// Dictionary DiyInterests { get; } + + + +// [Required] +// public string Status { get; set; } = string.Empty; +// [Required] +// public DateTime Date { get; set; } +// [Required] +// public int ManagerId { get; set; } +// public virtual Manager Manager { get; set; } +// private Dictionary? _FurnitureId = null; +// [NotMapped] +// public Dictionary FurnitureId +// { +// get +// { +// if (_FurnitureId == null) +// { +// _FurnitureId = Furniture +// .ToDictionary(recPC => recPC.FurnitureId, recPC => (recPC.Furniture as IFurniture)); +// } +// return _FurnitureId; +// } +// } + +// public int Id { get; set; } +// [ForeignKey("OrdersId")] +// public virtual List Interests { get; set; } = new(); +// public static Diy Create(SchoolDataBase context, DiyBindingModel model) +// { +// return new Diy() +// { +// Id = model.Id, +// Title = model.Title, +// Description = model.Description, +// DateCreate = model.DateCreate, +// TaskId = model.TaskId, +// TaskName = model.TaskName, +// StudentId = model.StudentId, +// StudentName = model.StudentName, +// Interests = model.DiyInterests.Select(x => new DiyInterest +// { +// Interest = context.Interests.First(y => y.Id == x.Key), +// }).ToList() +// }; +// } + +// public void Update(OrdersBindingModel model) +// { +// Status = model.Status; +// Date = model.Date; +// } + +// public OrdersViewModel GetViewModel => new() +// { +// Id = Id, +// Status=Status, +// Date = Date, +// ManagerId = ManagerId, +// FurnitureId = FurnitureId +// }; + +// public void UpdateInterests(FurnitureDataBase context, OrdersBindingModel model) +// { +// var diyInterests = context.DiyInterests.Where(rec => rec.DiyId == model.Id).ToList(); +// if (diyInterests != null && diyInterests.Count > 0) +// { +// context.DiyInterests.RemoveRange(diyInterests.Where(rec => !model.DiyInterests.ContainsKey(rec.InterestId))); +// context.SaveChanges(); + +// foreach (var updateInterest in diyInterests) +// { +// model.DiyInterests.Remove(updateInterest.InterestId); +// } +// context.SaveChanges(); +// } +// var diy = context.Diys.First(x => x.Id == Id); +// foreach (var pc in model.DiyInterests) +// { +// context.DiyInterests.Add(new DiyInterest +// { +// Diy = diy, +// Interest = context.Interests.First(x => x.Id == pc.Key), +// }); +// context.SaveChanges(); +// } +// _DiyInterests = null; +// } + +// } +//} diff --git a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/OrdersSalesSalons.cs b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/OrdersSalesSalons.cs new file mode 100644 index 0000000..ee99971 --- /dev/null +++ b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/OrdersSalesSalons.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureFactoryDataBaseImplement.Models +{ + internal class OrdersSalesSalons + { + } +} diff --git a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/SalesSalons.cs b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/SalesSalons.cs new file mode 100644 index 0000000..27341ba --- /dev/null +++ b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/SalesSalons.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using FurnitureFactoryDataModels.Models; +using System.ComponentModel; +using FurnitureContracts.BindingModels; +using FurnitureContracts.ViewModel; + +namespace FurnitureFactoryDataBaseImplement.Models +{ + internal class SalesSalons + { + //[DisplayName("Название")] + //public string Name { get; set; } = string.Empty; + //[DisplayName("Адресс")] + //public string Address { get; set; } = string.Empty; + //public int Id { get; set; } + //public int ManagerId { get; set; } + + + + //public int StudentId { get; set; } + //[DisplayName("Название")] + //public string Title { get; set; } = string.Empty; + //[DisplayName("Описание")] + //public string Description { get; set; } = string.Empty; + //[DisplayName("Номер")] + //public int Id { get; set; } + + + [Required] + public string Name { get; set; } = string.Empty; + [Required] + public string Address { get; set; } = string.Empty; + + public int Id { get; set; } + [Required] + public int ManagerId { get; set; } + public virtual Manager Manager { get; set; } + [ForeignKey("HeadsetId")] + public virtual List HeadsetSalesSalons { get; set; } = new(); + [ForeignKey("OrdersId")] + public virtual List OrdersSalesSalons { get; set; } = new(); + + public static SalesSalons? Create(SalesSalonsBindingModel model) + { + if (model == null) + { + return null; + } + return new SalesSalons() + { + Id = model.Id, + Name = model.Name, + Address = model.Address, + ManagerId = model.ManagerId, + }; + } + + public void Update(SalesSalonsBindingModel model) + { + if (model == null) + { + return; + } + Name = model.Name; + Address = model.Address; + } + + public SalesSalonsViewModel GetViewModel => new() + { + Id = Id, + Name = Name, + Address = Address, + ManagerId = ManagerId, + }; + } +} diff --git a/FurnitureFactory/FurnitureFactoryDataModels/Models/IHeadsetModel.cs b/FurnitureFactory/FurnitureFactoryDataModels/Models/IHeadsetModel.cs index cc3dbf6..45c7204 100644 --- a/FurnitureFactory/FurnitureFactoryDataModels/Models/IHeadsetModel.cs +++ b/FurnitureFactory/FurnitureFactoryDataModels/Models/IHeadsetModel.cs @@ -10,7 +10,8 @@ namespace FurnitureFactoryDataModels.Models { int Cost { get;} string Size { get; } - public Dictionary HeadsetModuleId { get; } + public Dictionary SalesSalonsId { get; } int ManagerId { get; } + int HeadsetModuleId { get; } } } diff --git a/FurnitureFactory/FurnitureFactoryDataModels/Models/IOrdersModel.cs b/FurnitureFactory/FurnitureFactoryDataModels/Models/IOrdersModel.cs index ae73ff5..62e461d 100644 --- a/FurnitureFactory/FurnitureFactoryDataModels/Models/IOrdersModel.cs +++ b/FurnitureFactory/FurnitureFactoryDataModels/Models/IOrdersModel.cs @@ -10,7 +10,7 @@ namespace FurnitureFactoryDataModels.Models { DateTime Date { get; } string Status { get; } - public Dictionary FurnitureId { get; } + public Dictionary SalesSalonsId { get; } int ManagerId { get; } } } diff --git a/FurnitureFactory/FurnitureFactoryDataModels/Models/ISalesSalonsModel.cs b/FurnitureFactory/FurnitureFactoryDataModels/Models/ISalesSalonsModel.cs index f851406..7c8f692 100644 --- a/FurnitureFactory/FurnitureFactoryDataModels/Models/ISalesSalonsModel.cs +++ b/FurnitureFactory/FurnitureFactoryDataModels/Models/ISalesSalonsModel.cs @@ -10,7 +10,6 @@ namespace FurnitureFactoryDataModels.Models { string Name { get; } string Address { get; } - public Dictionary OrdersId { get; } int ManagerId { get; } } }