From d040b5293bc3b353f0e340a9e5026584e21911a0 Mon Sep 17 00:00:00 2001 From: FLARJ <122087628+FLARJ@users.noreply.github.com> Date: Fri, 7 Apr 2023 15:38:47 +0400 Subject: [PATCH] FurnitureFactoryDataBaseImplement Models --- .../BindingModels/HeadsetBindingModel.cs | 2 +- .../BindingModels/ManagerBindingModel.cs | 1 + .../BindingModels/OrdersBindingModel.cs | 2 +- .../SearchModels/ManagerSearchModel.cs | 1 + .../ViewModel/HeadsetViewModel.cs | 4 +- .../ViewModel/ManagerViewModel.cs | 6 +- .../ViewModel/OrdersViewModel.cs | 2 +- .../FurnitureDataBaseImplement.csproj | 5 +- .../FurnitureFactoryDataBaseImplement.csproj | 9 + .../Models/Furniture.cs | 12 + .../Models/Headset.cs | 94 +++++++- .../Models/HeadsetModule.cs | 12 + .../Models/HeadsetSalesSalons.cs | 2 +- .../Models/Manager.cs | 64 +++++- .../Models/Orders.cs | 209 ++++++++---------- .../Models/OrdersSalesSalons.cs | 10 +- .../Models/SalesSalons.cs | 23 +- .../Models/IHeadsetModel.cs | 2 +- .../Models/IManagerModel.cs | 2 + .../Models/IOrdersModel.cs | 2 +- 20 files changed, 310 insertions(+), 154 deletions(-) create mode 100644 FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Furniture.cs create mode 100644 FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/HeadsetModule.cs diff --git a/FurnitureFactory/FurnitureContracts/BindingModels/HeadsetBindingModel.cs b/FurnitureFactory/FurnitureContracts/BindingModels/HeadsetBindingModel.cs index 7764f48..4afb4ff 100644 --- a/FurnitureFactory/FurnitureContracts/BindingModels/HeadsetBindingModel.cs +++ b/FurnitureFactory/FurnitureContracts/BindingModels/HeadsetBindingModel.cs @@ -9,6 +9,6 @@ namespace FurnitureContracts.BindingModels public int Id { get; set; } public int ManagerId { get; set; } public int HeadsetModuleId { get; set; } - public Dictionary SalesSalonsId { get; set; } + public Dictionary HeadsetSalesSalons { get; set; } } } diff --git a/FurnitureFactory/FurnitureContracts/BindingModels/ManagerBindingModel.cs b/FurnitureFactory/FurnitureContracts/BindingModels/ManagerBindingModel.cs index a8a3c1f..adfdfd0 100644 --- a/FurnitureFactory/FurnitureContracts/BindingModels/ManagerBindingModel.cs +++ b/FurnitureFactory/FurnitureContracts/BindingModels/ManagerBindingModel.cs @@ -7,6 +7,7 @@ namespace FurnitureContracts.BindingModels public string UserName { get; set; } = string.Empty; public string Login { get; set; } = string.Empty; public string Password { get; set; } = string.Empty; + public string Email { 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 a938a4e..f8268e6 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 SalesSalonsId { get; set; } + public Dictionary OrdersSalesSalons { get; set; } } } diff --git a/FurnitureFactory/FurnitureContracts/SearchModels/ManagerSearchModel.cs b/FurnitureFactory/FurnitureContracts/SearchModels/ManagerSearchModel.cs index a6d47d8..8c15acb 100644 --- a/FurnitureFactory/FurnitureContracts/SearchModels/ManagerSearchModel.cs +++ b/FurnitureFactory/FurnitureContracts/SearchModels/ManagerSearchModel.cs @@ -10,5 +10,6 @@ namespace FurnitureContracts.SearchModels { public string? UserName { get; set; } public int? Id { get; set; } + public string? Login { get; set; } } } diff --git a/FurnitureFactory/FurnitureContracts/ViewModel/HeadsetViewModel.cs b/FurnitureFactory/FurnitureContracts/ViewModel/HeadsetViewModel.cs index 24b84aa..abd101b 100644 --- a/FurnitureFactory/FurnitureContracts/ViewModel/HeadsetViewModel.cs +++ b/FurnitureFactory/FurnitureContracts/ViewModel/HeadsetViewModel.cs @@ -16,7 +16,9 @@ namespace FurnitureContracts.ViewModel [DisplayName("Размер")] public string Size { get; set; } = string.Empty; public int Id { get; set; } - public Dictionary HeadsetModuleId { get; } + public int HeadsetModuleId { get; set; } + public int ManagerId { get; set; } + public Dictionary HeadsetSalesSalons { get; set; } } } diff --git a/FurnitureFactory/FurnitureContracts/ViewModel/ManagerViewModel.cs b/FurnitureFactory/FurnitureContracts/ViewModel/ManagerViewModel.cs index bae41a0..f678e9f 100644 --- a/FurnitureFactory/FurnitureContracts/ViewModel/ManagerViewModel.cs +++ b/FurnitureFactory/FurnitureContracts/ViewModel/ManagerViewModel.cs @@ -7,10 +7,12 @@ namespace FurnitureContracts.ViewModel { [DisplayName("Имя пользователя")] public string UserName { get; set; } = string.Empty; + [DisplayName("Номер")] public int Id { get; set; } [DisplayName("Логин")] public string Login { get; set; } = string.Empty; - public string Password { get; } - public string Role { get; } + public string Password { get; set; } = string.Empty; + public string Role { get; set; } = string.Empty; + public string Email { get; set; } = string.Empty; } } diff --git a/FurnitureFactory/FurnitureContracts/ViewModel/OrdersViewModel.cs b/FurnitureFactory/FurnitureContracts/ViewModel/OrdersViewModel.cs index 2c9b741..c0d420f 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 SalesSalonsId { get; set; } + public Dictionary OrdersSalesSalons { get; set; } } } diff --git a/FurnitureFactory/FurnitureDataBaseImplement/FurnitureDataBaseImplement.csproj b/FurnitureFactory/FurnitureDataBaseImplement/FurnitureDataBaseImplement.csproj index 416ed03..f2c9493 100644 --- a/FurnitureFactory/FurnitureDataBaseImplement/FurnitureDataBaseImplement.csproj +++ b/FurnitureFactory/FurnitureDataBaseImplement/FurnitureDataBaseImplement.csproj @@ -8,10 +8,7 @@ - - - - + diff --git a/FurnitureFactory/FurnitureFactoryDataBaseImplement/FurnitureFactoryDataBaseImplement.csproj b/FurnitureFactory/FurnitureFactoryDataBaseImplement/FurnitureFactoryDataBaseImplement.csproj index 132c02c..9efcd71 100644 --- a/FurnitureFactory/FurnitureFactoryDataBaseImplement/FurnitureFactoryDataBaseImplement.csproj +++ b/FurnitureFactory/FurnitureFactoryDataBaseImplement/FurnitureFactoryDataBaseImplement.csproj @@ -6,4 +6,13 @@ enable + + + + + + + + + diff --git a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Furniture.cs b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Furniture.cs new file mode 100644 index 0000000..143f0ed --- /dev/null +++ b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Furniture.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureFactoryDataBaseImplement.Models +{ + public class Furniture + { + } +} diff --git a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Headset.cs b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Headset.cs index 89bdc62..c084d9b 100644 --- a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Headset.cs +++ b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Headset.cs @@ -1,12 +1,104 @@ 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 FurnitureContracts.BindingModels; +using FurnitureContracts.ViewModel; +using FurnitureContracts.SearchModels; namespace FurnitureFactoryDataBaseImplement.Models { - internal class Headset + public class Headset { + [Required] + public string Size { get; set; } = string.Empty; + [Required] + public int HeadsetModuleId { get; set; } + [Required] + public int Cost { get; set; } + [Required] + public virtual HeadsetModule HeadsetModule { get; set; } + [Required] + public int ManagerId { get; set; } + public virtual Manager Manager { get; set; } + private Dictionary? _HeadsetSalesSalons = null; + [NotMapped] + public Dictionary HeadsetSalesSalons + { + get + { + if (_HeadsetSalesSalons == null) + { + _HeadsetSalesSalons = SalesSalons + .ToDictionary(recPC => recPC.SalesSalonsId, recPC => (recPC.SalesSalons as ISalesSalonsModel)); + } + return _HeadsetSalesSalons; + } + } + + public int Id { get; set; } + [ForeignKey("HeadsetId")] + public virtual List SalesSalons { get; set; } = new(); + public static Headset Create(FurnitureDataBase context, HeadsetBindingModel model) + { + return new Headset() + { + Id = model.Id, + Size = model.Size, + HeadsetModuleId = model.HeadsetModuleId, + ManagerId = model.ManagerId, + SalesSalons = model.HeadsetSalesSalons.Select(x => new HeadsetSalesSalons + { + SalesSalons = context.SalesSalons.First(y => y.Id == x.Key), + }).ToList() + }; + } + + public void Update(HeadsetBindingModel model) + { + Cost = model.Cost; + Size = model.Size; + } + + public HeadsetViewModel GetViewModel => new() + { + Id = Id, + Size = Size, + Cost = Cost, + HeadsetModuleId = HeadsetModuleId, + ManagerId = ManagerId, + HeadsetSalesSalons = HeadsetSalesSalons + }; + + public void UpdateInterests(FurnitureDataBase context, HeadsetBindingModel model) + { + var headsetSalesSalons = context.HeadsetSalesSalons.Where(rec => rec.HeadsetId == model.Id).ToList(); + if (headsetSalesSalons != null && HeadsetSalesSalons.Count > 0) + { + context.HeadsetSalesSalons.RemoveRange(headsetSalesSalons.Where(rec => !model.HeadsetSalesSalons.ContainsKey(rec.SalesSalonsId))); + context.SaveChanges(); + + foreach (var updateSalesSalons in headsetSalesSalons) + { + model.HeadsetSalesSalons.Remove(updateSalesSalons.SalesSalonsId); + } + context.SaveChanges(); + } + var headset = context.Headsets.First(x => x.Id == Id); + foreach (var pc in model.HeadsetSalesSalons) + { + context.HeadsetSalesSalons.Add(new HeadsetSalesSalons + { + Headset = headset, + SalesSalons = context.SalesSalons.First(x => x.Id == pc.Key), + }); + context.SaveChanges(); + } + _HeadsetSalesSalons = null; + } } } diff --git a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/HeadsetModule.cs b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/HeadsetModule.cs new file mode 100644 index 0000000..500394d --- /dev/null +++ b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/HeadsetModule.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureFactoryDataBaseImplement.Models +{ + public class HeadsetModule + { + } +} diff --git a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/HeadsetSalesSalons.cs b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/HeadsetSalesSalons.cs index 4f7ba58..f52cbec 100644 --- a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/HeadsetSalesSalons.cs +++ b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/HeadsetSalesSalons.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace FurnitureFactoryDataBaseImplement.Models { - internal class HeadsetSalesSalons + public class HeadsetSalesSalons { public int Id { get; set; } [Required] diff --git a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Manager.cs b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Manager.cs index ea19f48..007c784 100644 --- a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Manager.cs +++ b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Manager.cs @@ -1,12 +1,70 @@ -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; +using FurnitureContracts.SearchModels; namespace FurnitureFactoryDataBaseImplement.Models { - internal class Manager + public class Manager { + [Required] + public string UserName { get; set; } = string.Empty; + [Required] + public string Role { get; set; } + [Required] + public string Email { get; set; } = string.Empty; + [Required] + public string Login { get; set; } = string.Empty; + [Required] + public string Password { get; set; } = string.Empty; + + public int Id { get; set; } + + [ForeignKey("ManagerId")] + public virtual List SalesSalons { get; set; } = new(); + [ForeignKey("ManagerId")] + public virtual List Headsets { get; set; } = new(); + [ForeignKey("ManagerId")] + public virtual List Orders { get; set; } = new(); + public static Manager Create(FurnitureDataBase context, ManagerBindingModel model) + { + return new Manager() + { + Id = model.Id, + UserName = model.UserName, + Role = model.Role, + Email = model.Email, + Login = model.Login, + Password = model.Password, + + }; + } + + public void Update(ManagerBindingModel model) + { + UserName = model.UserName; + Role = model.Role; + Email = model.Email; + Login = model.Login; + Password = model.Password; + } + + public ManagerViewModel GetViewModel => new() + { + Id = Id, + UserName = UserName, + Role = Role, + Email = Email, + Login = Login, + Password = Password + + }; } } diff --git a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Orders.cs b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Orders.cs index 390d2f5..7c8738e 100644 --- a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Orders.cs +++ b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Orders.cs @@ -1,124 +1,101 @@ -//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; +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 Orders : IOrders -// { -// // мое -// //DateTime Date { get; } -// //string Status { get; } -// //public Dictionary FurnitureId { get; } -// //int ManagerId { get; } +namespace FurnitureFactoryDataBaseImplement.Models +{ + public class Orders : IOrdersModel + { + [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? _OrdersSalesSalons = null; + [NotMapped] + public Dictionary OrdersSalesSalons + { + get + { + if (_OrdersSalesSalons == null) + { + _OrdersSalesSalons = SalesSalons + .ToDictionary(recPC => recPC.SalesSalonsId, recPC => (recPC.SalesSalons as ISalesSalonsModel)); + } + return _OrdersSalesSalons; + } + } -// string Title { get; } -// string Description { get; } -// string? TaskName { get; } -// DateTime DateCreate { get; } -// int TaskId { get; } -// int StudentId { get; } -// string StudentName { get; } -// Dictionary DiyInterests { get; } + public int Id { get; set; } + [ForeignKey("OrdersId")] + public virtual List SalesSalons { get; set; } = new(); + [ForeignKey("OrdersId")] + public virtual List Furniture { get; set; } = new(); + public static Orders Create(FurnitureDataBase context, OrdersBindingModel model) + { + return new Orders() + { + Id = model.Id, + Status = model.Status, + Date = model.Date, + ManagerId = model.ManagerId, + SalesSalons = model.OrdersSalesSalons.Select(x => new OrdersSalesSalons + { + SalesSalons = context.SalesSalons.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, + OrdersSalesSalons = OrdersSalesSalons + }; -// [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 void UpdateInterests(FurnitureDataBase context, OrdersBindingModel model) + { + var ordersSalesSalons = context.OrdersSalesSalons.Where(rec => rec.OrdersId == model.Id).ToList(); + if (ordersSalesSalons != null && OrdersSalesSalons.Count > 0) + { + context.OrdersSalesSalons.RemoveRange(ordersSalesSalons.Where(rec => !model.OrdersSalesSalons.ContainsKey(rec.SalesSalonsId))); + context.SaveChanges(); -// 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; -// } - -// } -//} + foreach (var updateSalesSalons in ordersSalesSalons) + { + model.OrdersSalesSalons.Remove(updateSalesSalons.SalesSalonsId); + } + context.SaveChanges(); + } + var orders = context.Orders.First(x => x.Id == Id); + foreach (var pc in model.OrdersSalesSalons) + { + context.OrdersSalesSalons.Add(new OrdersSalesSalons + { + Orders = orders, + SalesSalons = context.SalesSalons.First(x => x.Id == pc.Key), + }); + context.SaveChanges(); + } + _OrdersSalesSalons = null; + } + } +} diff --git a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/OrdersSalesSalons.cs b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/OrdersSalesSalons.cs index ee99971..1fc0bbf 100644 --- a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/OrdersSalesSalons.cs +++ b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/OrdersSalesSalons.cs @@ -1,12 +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 OrdersSalesSalons + public class OrdersSalesSalons { + public int Id { get; set; } + [Required] + public int OrdersId { get; set; } + [Required] + public int SalesSalonsId { get; set; } + public virtual Orders Orders { get; set; } = new(); + public virtual SalesSalons SalesSalons { get; set; } = new(); } } diff --git a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/SalesSalons.cs b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/SalesSalons.cs index 27341ba..7a25c0c 100644 --- a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/SalesSalons.cs +++ b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/SalesSalons.cs @@ -12,25 +12,8 @@ using FurnitureContracts.ViewModel; namespace FurnitureFactoryDataBaseImplement.Models { - internal class SalesSalons + public 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; @@ -41,9 +24,9 @@ namespace FurnitureFactoryDataBaseImplement.Models [Required] public int ManagerId { get; set; } public virtual Manager Manager { get; set; } - [ForeignKey("HeadsetId")] + [ForeignKey("SalesSalonsId")] public virtual List HeadsetSalesSalons { get; set; } = new(); - [ForeignKey("OrdersId")] + [ForeignKey("SalesSalonsId")] public virtual List OrdersSalesSalons { get; set; } = new(); public static SalesSalons? Create(SalesSalonsBindingModel model) diff --git a/FurnitureFactory/FurnitureFactoryDataModels/Models/IHeadsetModel.cs b/FurnitureFactory/FurnitureFactoryDataModels/Models/IHeadsetModel.cs index 45c7204..b6bf794 100644 --- a/FurnitureFactory/FurnitureFactoryDataModels/Models/IHeadsetModel.cs +++ b/FurnitureFactory/FurnitureFactoryDataModels/Models/IHeadsetModel.cs @@ -10,7 +10,7 @@ namespace FurnitureFactoryDataModels.Models { int Cost { get;} string Size { get; } - public Dictionary SalesSalonsId { get; } + public Dictionary HeadsetSalesSalons { get; } int ManagerId { get; } int HeadsetModuleId { get; } } diff --git a/FurnitureFactory/FurnitureFactoryDataModels/Models/IManagerModel.cs b/FurnitureFactory/FurnitureFactoryDataModels/Models/IManagerModel.cs index 672c57d..96ec69e 100644 --- a/FurnitureFactory/FurnitureFactoryDataModels/Models/IManagerModel.cs +++ b/FurnitureFactory/FurnitureFactoryDataModels/Models/IManagerModel.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -10,6 +11,7 @@ namespace FurnitureFactoryDataModels.Models { string Login { get; } string Password { get; } + string Email { get; } string Role { get; } string UserName { get; } } diff --git a/FurnitureFactory/FurnitureFactoryDataModels/Models/IOrdersModel.cs b/FurnitureFactory/FurnitureFactoryDataModels/Models/IOrdersModel.cs index 62e461d..82034fa 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 SalesSalonsId { get; } + public Dictionary OrdersSalesSalons { get; } int ManagerId { get; } } }