From 2119b1cc33c59a2291478d7fbb97317debb2a292 Mon Sep 17 00:00:00 2001 From: Ismailov_Rovshan Date: Sat, 8 Apr 2023 16:14:43 +0400 Subject: [PATCH] Storage --- .../HeadsetModuleBindingModel.cs | 2 +- .../SearchModels/FurnitureSearchModel.cs | 4 + .../SearchModels/HeadsetModuleSearchModel.cs | 4 +- .../SearchModels/MasterSearchModel.cs | 1 + .../SearchModels/MaterialSearchModel.cs | 1 + .../FurnitureDataBase.cs | 6 +- .../Implements/FurnitureStorage.cs | 121 +++++++++++++++++ .../Implements/HeadsetModuleStorage.cs | 122 ++++++++++++++++++ .../Implements/MasterStorage.cs | 101 +++++++++++++++ .../Implements/MaterialStorage.cs | 88 +++++++++++++ .../Models/Furniture.cs | 8 +- .../Models/FurnitureMaterial.cs | 1 - .../Models/HeadsetModule.cs | 15 ++- .../Models/HeadsetModuleMaterial.cs | 2 +- .../Models/Master.cs | 2 +- .../Models/IFurnitureModel.cs | 3 +- .../Models/IHeadsetModuleModel.cs | 3 + 17 files changed, 470 insertions(+), 14 deletions(-) create mode 100644 FurnitureFactory/FurnitureFactoryDataBaseImplement/Implements/FurnitureStorage.cs create mode 100644 FurnitureFactory/FurnitureFactoryDataBaseImplement/Implements/HeadsetModuleStorage.cs create mode 100644 FurnitureFactory/FurnitureFactoryDataBaseImplement/Implements/MasterStorage.cs create mode 100644 FurnitureFactory/FurnitureFactoryDataBaseImplement/Implements/MaterialStorage.cs diff --git a/FurnitureFactory/FurnitureContracts/BindingModels/HeadsetModuleBindingModel.cs b/FurnitureFactory/FurnitureContracts/BindingModels/HeadsetModuleBindingModel.cs index 47b678e..68db926 100644 --- a/FurnitureFactory/FurnitureContracts/BindingModels/HeadsetModuleBindingModel.cs +++ b/FurnitureFactory/FurnitureContracts/BindingModels/HeadsetModuleBindingModel.cs @@ -19,6 +19,6 @@ namespace FurnitureContracts.BindingModels public string MasterName { get; set; } = string.Empty; - public Dictionary HeadsetModuleMaterial { get; set; }; + public Dictionary HeadsetModuleMaterial { get; set; } } } diff --git a/FurnitureFactory/FurnitureContracts/SearchModels/FurnitureSearchModel.cs b/FurnitureFactory/FurnitureContracts/SearchModels/FurnitureSearchModel.cs index b45a12d..05416d7 100644 --- a/FurnitureFactory/FurnitureContracts/SearchModels/FurnitureSearchModel.cs +++ b/FurnitureFactory/FurnitureContracts/SearchModels/FurnitureSearchModel.cs @@ -10,5 +10,9 @@ namespace FurnitureContracts.SearchModels { public string? Name { get; set; } public int? Id { get; set; } + public int? MasterId { get; set; } + public DateTime? DateFrom { get; set; } + + public DateTime? DateTo { get; set; } } } diff --git a/FurnitureFactory/FurnitureContracts/SearchModels/HeadsetModuleSearchModel.cs b/FurnitureFactory/FurnitureContracts/SearchModels/HeadsetModuleSearchModel.cs index 9d98bac..75738eb 100644 --- a/FurnitureFactory/FurnitureContracts/SearchModels/HeadsetModuleSearchModel.cs +++ b/FurnitureFactory/FurnitureContracts/SearchModels/HeadsetModuleSearchModel.cs @@ -8,8 +8,10 @@ namespace FurnitureContracts.SearchModels { public class HeadsetModuleSearchModel { - public string? Title { get; set; } + public DateTime? DateFrom { get; set; } + public DateTime? DateTo { get; set; } public string? Name { get; set; } public int? Id { get; set; } + public int ? MasterId { get; set; } } } diff --git a/FurnitureFactory/FurnitureContracts/SearchModels/MasterSearchModel.cs b/FurnitureFactory/FurnitureContracts/SearchModels/MasterSearchModel.cs index 8a68033..a4da78a 100644 --- a/FurnitureFactory/FurnitureContracts/SearchModels/MasterSearchModel.cs +++ b/FurnitureFactory/FurnitureContracts/SearchModels/MasterSearchModel.cs @@ -9,6 +9,7 @@ namespace FurnitureContracts.SearchModels public class MasterSearchModel { public string? Name { get; set; } + public string? Login { get; set; } public int? Id { get; set; } } } diff --git a/FurnitureFactory/FurnitureContracts/SearchModels/MaterialSearchModel.cs b/FurnitureFactory/FurnitureContracts/SearchModels/MaterialSearchModel.cs index 050f1fa..421b451 100644 --- a/FurnitureFactory/FurnitureContracts/SearchModels/MaterialSearchModel.cs +++ b/FurnitureFactory/FurnitureContracts/SearchModels/MaterialSearchModel.cs @@ -10,5 +10,6 @@ namespace FurnitureContracts.SearchModels { public string? Name { get; set; } public int? Id { get; set; } + public int? MasterId { get; set; } } } diff --git a/FurnitureFactory/FurnitureFactoryDataBaseImplement/FurnitureDataBase.cs b/FurnitureFactory/FurnitureFactoryDataBaseImplement/FurnitureDataBase.cs index e0c39c2..09594c2 100644 --- a/FurnitureFactory/FurnitureFactoryDataBaseImplement/FurnitureDataBase.cs +++ b/FurnitureFactory/FurnitureFactoryDataBaseImplement/FurnitureDataBase.cs @@ -36,8 +36,12 @@ namespace FurnitureFactoryDataBaseImplement public virtual DbSet HeadsetSalesSalons { set; get; } public virtual DbSet Orders { set; get; } public virtual DbSet OrdersSalesSalons { set; get; } + public virtual DbSet HeadsetModules { set; get; } + public virtual DbSet FurnitureMaterials { set; get; } + public virtual DbSet Furnitures { set; get; } + public virtual DbSet Masters { set; get; } - //public virtual DbSet Masters { set; get; } + public virtual DbSet HeadsetModuleMaterials { set; get; } public virtual DbSet Materials { set; get; } diff --git a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Implements/FurnitureStorage.cs b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Implements/FurnitureStorage.cs new file mode 100644 index 0000000..16baf24 --- /dev/null +++ b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Implements/FurnitureStorage.cs @@ -0,0 +1,121 @@ +using FurnitureContracts.BindingModels; +using FurnitureContracts.SearchModels; +using FurnitureContracts.StoragesContracts; +using FurnitureContracts.ViewModel; +using FurnitureFactoryDataBaseImplement.Models; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureFactoryDataBaseImplement.Implements +{ + public class FurnitureStorage : IFurnitureStorage + { + public List GetFullList() + { + using var context = new FurnitureDataBase(); + return context.Furnitures + .Include(x => x.Materials) + .ThenInclude(x => x.Material) + .ToList() + .Select(x => x.GetViewModel) + .ToList(); + } + + public List GetFilteredList( FurnitureSearchModel model) + { + if (!model.MasterId.HasValue) + { + return new(); + } + using var context = new FurnitureDataBase(); + if (model.MasterId.HasValue && model.DateTo.HasValue) + { + return context. Furnitures + .Include(x => x.Materials) + .ThenInclude(x => x.Material) + .Where(x => x.DateTo >= model.DateFrom && x.DateTo <= model.DateTo && x.MasterId == model.MasterId) + .ToList() + .Select(x => x.GetViewModel) + .ToList(); + } + return context. Furnitures + .Include(x => x.Materials) + .ThenInclude(x => x.Material) + .Where(x => x.MasterId == model.MasterId) + .ToList() + .Select(x => x.GetViewModel) + .ToList(); + } + + public FurnitureViewModel? GetElement( FurnitureSearchModel model) + { + if ((string.IsNullOrEmpty(model.Name) && !model.Id.HasValue) || !model.MasterId.HasValue) + { + return null; + } + using var context = new FurnitureDataBase(); + return context. Furnitures + .Include(x => x.Materials) + .ThenInclude(x => x.Material) + .FirstOrDefault(x => ((!string.IsNullOrEmpty(model.Name) && x.Name == model.Name) || + (model.Id.HasValue && x.Id == model.Id)) && x.MasterId == model.MasterId) + ?.GetViewModel; + } + + public FurnitureViewModel? Insert( FurnitureBindingModel model) + { + using var context = new FurnitureDataBase(); + var newFurniture = Furniture.Create(context, model); + if (newFurniture == null) + { + return null; + } + context. Furnitures.Add(newFurniture); + context.SaveChanges(); + return newFurniture.GetViewModel; + } + + public FurnitureViewModel? Update( FurnitureBindingModel model) + { + using var context = new FurnitureDataBase(); + using var transaction = context.Database.BeginTransaction(); + try + { + var Furniture = context. Furnitures.FirstOrDefault(rec => rec.Id == model.Id); + if ( Furniture == null) + { + return null; + } + Furniture.Update(model); + context.SaveChanges(); + Furniture.UpdateMaterials(context, model); + transaction.Commit(); + return Furniture.GetViewModel; + } + catch + { + transaction.Rollback(); + throw; + } + } + + public FurnitureViewModel? Delete( FurnitureBindingModel model) + { + using var context = new FurnitureDataBase(); + var element = context. Furnitures + .Include(x => x.Materials) + .FirstOrDefault(rec => rec.Id == model.Id); + if (element != null) + { + context. Furnitures.Remove(element); + context.SaveChanges(); + return element.GetViewModel; + } + return null; + } + } +} diff --git a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Implements/HeadsetModuleStorage.cs b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Implements/HeadsetModuleStorage.cs new file mode 100644 index 0000000..d1e4fcf --- /dev/null +++ b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Implements/HeadsetModuleStorage.cs @@ -0,0 +1,122 @@ +using FurnitureContracts.BindingModels; +using FurnitureContracts.SearchModels; +using FurnitureContracts.StoragesContracts; +using FurnitureContracts.ViewModel; +using FurnitureFactoryDataBaseImplement.Models; +using FurnitureFactoryDataModels.Models; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + + +namespace FurnitureFactoryDataBaseImplement.Implements +{ + public class HeadsetModuleStorage : IHeadsetModuleStorage + { + public List GetFullList() + { + using var context = new FurnitureDataBase(); + return context.HeadsetModules + .Include(x => x.Materials) + .ThenInclude(x => x.Material) + .ToList() + .Select(x => x.GetViewModel) + .ToList(); + } + + public List GetFilteredList(HeadsetModuleSearchModel model) + { + if (!model.MasterId.HasValue) + { + return new(); + } + using var context = new FurnitureDataBase(); + if (model.MasterId.HasValue ) + { + return context.HeadsetModules + .Include(x => x.Materials) + .ThenInclude(x => x.Material) + .Where(x => x.DateIssue >= model.DateFrom && x.DateIssue <= model.DateTo && x.MasterId == model.MasterId) + .ToList() + .Select(x => x.GetViewModel) + .ToList(); + } + return context.HeadsetModules + .Include(x => x.Materials) + .ThenInclude(x => x.Material) + .Where(x => x.MasterId == model.MasterId) + .ToList() + .Select(x => x.GetViewModel) + .ToList(); + } + + public HeadsetModuleViewModel? GetElement(HeadsetModuleSearchModel model) + { + if ((string.IsNullOrEmpty(model.Name) && !model.Id.HasValue) || !model.MasterId.HasValue) + { + return null; + } + using var context = new FurnitureDataBase(); + return context.HeadsetModules + .Include(x => x.Materials) + .ThenInclude(x => x.Material) + .FirstOrDefault(x => ((!string.IsNullOrEmpty(model.Name) && x.Name == model.Name) || + (model.Id.HasValue && x.Id == model.Id)) && x.MasterId == model.MasterId) + ?.GetViewModel; + } + + public HeadsetModuleViewModel? Insert(HeadsetModuleBindingModel model) + { + using var context = new FurnitureDataBase(); + var newHeadsetModule = HeadsetModule.Create(context, model); + if (newHeadsetModule == null) + { + return null; + } + context.HeadsetModules.Add(newHeadsetModule); + context.SaveChanges(); + return newHeadsetModule.GetViewModel; + } + + public HeadsetModuleViewModel? Update(HeadsetModuleBindingModel model) + { + using var context = new FurnitureDataBase(); + using var transaction = context.Database.BeginTransaction(); + try + { + var HeadsetModule = context.HeadsetModules.FirstOrDefault(rec => rec.Id == model.Id); + if (HeadsetModule == null) + { + return null; + } + HeadsetModule.Update(model); + context.SaveChanges(); + HeadsetModule.UpdateMaterials(context, model); + transaction.Commit(); + return HeadsetModule.GetViewModel; + } + catch + { + transaction.Rollback(); + throw; + } + } + + public HeadsetModuleViewModel? Delete(HeadsetModuleBindingModel model) + { + using var context = new FurnitureDataBase(); + var element = context.HeadsetModules + .Include(x => x.Materials) + .FirstOrDefault(rec => rec.Id == model.Id); + if (element != null) + { + context.HeadsetModules.Remove(element); + context.SaveChanges(); + return element.GetViewModel; + } + return null; + } + } +} diff --git a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Implements/MasterStorage.cs b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Implements/MasterStorage.cs new file mode 100644 index 0000000..581de95 --- /dev/null +++ b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Implements/MasterStorage.cs @@ -0,0 +1,101 @@ +using FurnitureContracts.BindingModels; +using FurnitureContracts.SearchModels; +using FurnitureContracts.ViewModel; +using FurnitureFactoryDataBaseImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureFactoryDataBaseImplement.Implements +{ + public class MasterStorage + { + public MasterViewModel? Delete(MasterBindingModel model) + { + using var context = new FurnitureDataBase(); + var element = context.Masters + .FirstOrDefault(rec => rec.Id == model.Id); + if (element != null) + { + context.Masters.Remove(element); + context.SaveChanges(); + return element.GetViewModel; + } + return null; + } + + public MasterViewModel? GetElement(MasterSearchModel model) + { + if (string.IsNullOrEmpty(model.Login) && !model.Id.HasValue) + { + return null; + } + using var context = new FurnitureDataBase(); + return context.Masters + .FirstOrDefault(x => (!string.IsNullOrEmpty(model.Login) && x.Login == model.Login) || + (model.Id.HasValue && x.Id == model.Id)) + ?.GetViewModel; + } + + public List GetFilteredList(MasterSearchModel model) + { + if (string.IsNullOrEmpty(model.Name)) + { + return new(); + } + using var context = new FurnitureDataBase(); + return context.Masters + .Where(x => x.Name.Contains(model.Name)) + .ToList() + .Select(x => x.GetViewModel) + .ToList(); + } + + public List GetFullList() + { + using var context = new FurnitureDataBase(); + return context.Masters + .ToList() + .Select(x => x.GetViewModel) + .ToList(); + } + + public MasterViewModel? Insert(MasterBindingModel model) + { + using var context = new FurnitureDataBase(); + var newMaster = Master.Create(context, model); + if (newMaster == null) + { + return null; + } + context.Masters.Add(newMaster); + context.SaveChanges(); + return newMaster.GetViewModel; + } + + public MasterViewModel? Update(MasterBindingModel model) + { + using var context = new FurnitureDataBase(); + using var transaction = context.Database.BeginTransaction(); + try + { + var Master = context.Masters.FirstOrDefault(rec => rec.Id == model.Id); + if (Master == null) + { + return null; + } + Master.Update(model); + context.SaveChanges(); + transaction.Commit(); + return Master.GetViewModel; + } + catch + { + transaction.Rollback(); + throw; + } + } + } +} diff --git a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Implements/MaterialStorage.cs b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Implements/MaterialStorage.cs new file mode 100644 index 0000000..1f64ddd --- /dev/null +++ b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Implements/MaterialStorage.cs @@ -0,0 +1,88 @@ +using FurnitureContracts.BindingModels; +using FurnitureContracts.SearchModels; +using FurnitureContracts.StoragesContracts; +using FurnitureContracts.ViewModel; +using FurnitureFactoryDataBaseImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureFactoryDataBaseImplement.Implements +{ + internal class MaterialStorage : IMaterialStorage + { + public List GetFullList() + { + using var context = new FurnitureDataBase(); + return context.Materials + .Select(x => x.GetViewModel) + .ToList(); + } + + public List GetFilteredList(MaterialSearchModel model) + { + if (!model.MasterId.HasValue) + { + return new(); + } + using var context = new FurnitureDataBase(); + return context.Materials + .Where(x => x.MasterId == model.MasterId) + .Select(x => x.GetViewModel) + .ToList(); + } + public MaterialViewModel? GetElement(MaterialSearchModel model) + { + if ((string.IsNullOrEmpty(model.Name) && !model.Id.HasValue) || !model.MasterId.HasValue) + { + return null; + } + using var context = new FurnitureDataBase(); + return context.Materials + .FirstOrDefault(x => ((!string.IsNullOrEmpty(model.Name) && x.Name == model.Name) || + (model.Id.HasValue && x.Id == model.Id)) && x.MasterId == model.MasterId) + ?.GetViewModel; + } + + public MaterialViewModel? Insert(MaterialBindingModel model) + { + var newMaterial = Material.Create(model); + if (newMaterial == null) + { + return null; + } + using var context = new FurnitureDataBase(); + context.Materials.Add(newMaterial); + context.SaveChanges(); + return newMaterial.GetViewModel; + } + + public MaterialViewModel? Update(MaterialBindingModel model) + { + using var context = new FurnitureDataBase(); + var material = context.Materials.FirstOrDefault(x => x.Id == model.Id); + if (material == null) + { + return null; + } + material.Update(model); + context.SaveChanges(); + return material.GetViewModel; + } + + public MaterialViewModel? Delete(MaterialBindingModel model) + { + using var context = new FurnitureDataBase(); + var element = context.Materials.FirstOrDefault(rec => rec.Id == model.Id); + if (element != null) + { + context.Materials.Remove(element); + context.SaveChanges(); + return element.GetViewModel; + } + return null; + } + } +} diff --git a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Furniture.cs b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Furniture.cs index e3cd7b1..19e633d 100644 --- a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Furniture.cs +++ b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Furniture.cs @@ -47,7 +47,7 @@ namespace FurnitureFactoryDataBaseImplement.Models [ForeignKey("FurnitureId")] public virtual List Materials { get; set; } = new(); - public static Furniture Create(SchoolDataBase context, FurnitureBindingModel model) + public static Furniture Create(FurnitureDataBase context, FurnitureBindingModel model) { return new Furniture() { @@ -84,9 +84,11 @@ namespace FurnitureFactoryDataBaseImplement.Models - public Dictionary FurnitureMaterial => throw new NotImplementedException(); + - public void UpdateMaterials(SchoolDataBase context, FurnitureBindingModel model) + public DateTime DateTo { get; set; } + + public void UpdateMaterials(FurnitureDataBase context, FurnitureBindingModel model) { var FurnitureMaterials = context.FurnitureMaterials.Where(rec => rec.FurnitureId == model.Id).ToList(); if (FurnitureMaterials != null && FurnitureMaterials.Count > 0) diff --git a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/FurnitureMaterial.cs b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/FurnitureMaterial.cs index 77fe9b7..6cbc145 100644 --- a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/FurnitureMaterial.cs +++ b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/FurnitureMaterial.cs @@ -17,6 +17,5 @@ namespace FurnitureFactoryDataBaseImplement.Models public virtual Furniture Furniture { get; set; } = new(); public virtual Material Material { get; set; } = new(); - } } diff --git a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/HeadsetModule.cs b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/HeadsetModule.cs index aec2acb..c40acff 100644 --- a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/HeadsetModule.cs +++ b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/HeadsetModule.cs @@ -41,7 +41,7 @@ namespace FurnitureFactoryDataBaseImplement.Models public virtual List Headsets { get; set; } = new(); public int Id { get; set; } public string MasterName { get; set; } = string.Empty; - public static HeadsetModule Create(DateBase context, HeadsetModuleBindingModel model) + public static HeadsetModule Create(FurnitureDataBase context, HeadsetModuleBindingModel model) { return new HeadsetModule() { @@ -50,7 +50,7 @@ namespace FurnitureFactoryDataBaseImplement.Models Cost = model.Cost, MasterId = model.MasterId, MasterName = model.MasterName, - Headsets = model.HeadsetModuleMaterial.Select(x => new HeadsetModuleMaterial + Materials = model.HeadsetModuleMaterial.Select(x => new HeadsetModuleMaterial { Material = context.Materials.First(y => y.Id == x.Key), }).ToList() @@ -70,9 +70,16 @@ namespace FurnitureFactoryDataBaseImplement.Models MasterName = MasterName, HeadsetModuleMaterial = HeadsetModuleMaterial }; + + public DateTime DateIssue { get; set; } + + public DateTime DateDelivery { get; set; } + + public string Name { get; set; } = string.Empty; + public void UpdateMaterials(FurnitureDataBase context, HeadsetModuleBindingModel model) { - var headsetModule = context.HeadsetModulMaterial.Where(rec => rec.HeadsetModuleId == model.Id).ToList(); + var headsetModule = context.HeadsetModuleMaterials.Where(rec => rec.HeadsetModuleId == model.Id).ToList(); if (headsetModule != null && headsetModule.Count > 0) { context.HeadsetModuleMaterials.RemoveRange(headsetModule.Where(rec => !model.HeadsetModuleMaterial.ContainsKey(rec.MaterialId))); @@ -87,7 +94,7 @@ namespace FurnitureFactoryDataBaseImplement.Models var HeadsetModule = context.HeadsetModules.First(x => x.Id == Id); foreach (var pc in model.HeadsetModuleMaterial) { - context.HeadsetModuleMaterial.Add(new HeadsetModuleMaterial + context.HeadsetModuleMaterials.Add(new HeadsetModuleMaterial { HeadsetModule = HeadsetModule, Material = context.Materials.First(x => x.Id == pc.Key), diff --git a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/HeadsetModuleMaterial.cs b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/HeadsetModuleMaterial.cs index 9a25c78..74939de 100644 --- a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/HeadsetModuleMaterial.cs +++ b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/HeadsetModuleMaterial.cs @@ -11,7 +11,7 @@ namespace FurnitureFactoryDataBaseImplement.Models { public int Id { get; set; } [Required] - public int TaskId { get; set; } + public int HeadsetModuleId { get; set; } [Required] public int MaterialId { get; set; } public virtual HeadsetModule HeadsetModule { get; set; } = new(); diff --git a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Master.cs b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Master.cs index 1ba71aa..fff9ee5 100644 --- a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Master.cs +++ b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Master.cs @@ -29,7 +29,7 @@ namespace FurnitureFactoryDataBaseImplement.Models public virtual List Furnitures { get; set; } = new(); [ForeignKey("MasterId")] public virtual List HeadsetModules { get; set; } = new(); - public static Master Create(DateBase context, MasterBindingModel model) + public static Master Create(FurnitureDataBase context, MasterBindingModel model) { return new Master() { diff --git a/FurnitureFactory/FurnitureFactoryDataModels/Models/IFurnitureModel.cs b/FurnitureFactory/FurnitureFactoryDataModels/Models/IFurnitureModel.cs index be1b231..8d042e0 100644 --- a/FurnitureFactory/FurnitureFactoryDataModels/Models/IFurnitureModel.cs +++ b/FurnitureFactory/FurnitureFactoryDataModels/Models/IFurnitureModel.cs @@ -15,7 +15,8 @@ namespace FurnitureFactoryDataModels.Models int OrdersId { get; } string OrdersName { get; } string MasterName { get; } - public Dictionary FurnitureMaterial { get; } + public Dictionary FurnitureMaterials { get; } + DateTime DateTo { get; } } } diff --git a/FurnitureFactory/FurnitureFactoryDataModels/Models/IHeadsetModuleModel.cs b/FurnitureFactory/FurnitureFactoryDataModels/Models/IHeadsetModuleModel.cs index 550d86d..937433d 100644 --- a/FurnitureFactory/FurnitureFactoryDataModels/Models/IHeadsetModuleModel.cs +++ b/FurnitureFactory/FurnitureFactoryDataModels/Models/IHeadsetModuleModel.cs @@ -8,10 +8,13 @@ namespace FurnitureFactoryDataModels.Models { public interface IHeadsetModuleModel : IId { + string Name { get; } string Style { get;} int Cost { get;} int MasterId { get;} string MasterName { get; } public Dictionary HeadsetModuleMaterial { get; } + DateTime DateIssue { get; } + DateTime DateDelivery { get; } } }