From 76c9fa65805e4688d474e8efe78c62849ed50d2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=BE=D0=BB=D0=B0=D0=B9?= Date: Mon, 3 Apr 2023 19:52:40 +0400 Subject: [PATCH] =?UTF-8?q?=D1=83=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BB=D0=B8=D1=88=D0=BD=D0=B8=D1=85=20=D0=B8=D0=BD?= =?UTF-8?q?=D0=BA=D0=BB=D1=83=D0=B4=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HardwareShopContracts/ViewModels/BuildViewModel.cs | 3 --- .../HardwareShopContracts/ViewModels/CommentViewModel.cs | 3 --- .../HardwareShopContracts/ViewModels/PurchaseViewModel.cs | 3 --- .../Implements/Worker/BuildStorage.cs | 5 ----- .../Implements/Worker/CommentStorage.cs | 6 ------ .../Implements/Worker/PurchaseStorage.cs | 7 ------- .../HardwareShopDatabaseImplement/Models/Worker/Build.cs | 3 +-- .../HardwareShopDatabaseImplement/Models/Worker/Comment.cs | 1 - .../Models/Worker/Purchase.cs | 3 +-- 9 files changed, 2 insertions(+), 32 deletions(-) diff --git a/HardwareShop/HardwareShopContracts/ViewModels/BuildViewModel.cs b/HardwareShop/HardwareShopContracts/ViewModels/BuildViewModel.cs index cea63fe..c71783a 100644 --- a/HardwareShop/HardwareShopContracts/ViewModels/BuildViewModel.cs +++ b/HardwareShop/HardwareShopContracts/ViewModels/BuildViewModel.cs @@ -12,9 +12,6 @@ namespace HardwareShopContracts.ViewModels [DisplayName("Название Сборки")] public string BuildName { get; set; } = string.Empty; - [DisplayName("Логин пользователя")] - public string UserLogin { get; set; } = string.Empty; - public int UserId { get; set; } public Dictionary BuildPurchases { get; set; } = new(); diff --git a/HardwareShop/HardwareShopContracts/ViewModels/CommentViewModel.cs b/HardwareShop/HardwareShopContracts/ViewModels/CommentViewModel.cs index 6620922..0bcadd6 100644 --- a/HardwareShop/HardwareShopContracts/ViewModels/CommentViewModel.cs +++ b/HardwareShop/HardwareShopContracts/ViewModels/CommentViewModel.cs @@ -16,8 +16,5 @@ namespace HardwareShopContracts.ViewModels public int BuildId { get; set; } public int UserId { get; set; } - - [DisplayName("Логин пользователя")] - public string UserLogin { get; set; } = string.Empty; } } diff --git a/HardwareShop/HardwareShopContracts/ViewModels/PurchaseViewModel.cs b/HardwareShop/HardwareShopContracts/ViewModels/PurchaseViewModel.cs index ee1be3b..2a2c9a7 100644 --- a/HardwareShop/HardwareShopContracts/ViewModels/PurchaseViewModel.cs +++ b/HardwareShop/HardwareShopContracts/ViewModels/PurchaseViewModel.cs @@ -18,9 +18,6 @@ namespace HardwareShopContracts.ViewModels public int UserId { get; set; } - [DisplayName("Логин пользователя")] - public string UserLogin { get; set; } = string.Empty; - public Dictionary PurchaseGoods { get; set; } = new(); } } diff --git a/HardwareShop/HardwareShopDatabaseImplement/Implements/Worker/BuildStorage.cs b/HardwareShop/HardwareShopDatabaseImplement/Implements/Worker/BuildStorage.cs index cd6992f..34e12c6 100644 --- a/HardwareShop/HardwareShopDatabaseImplement/Implements/Worker/BuildStorage.cs +++ b/HardwareShop/HardwareShopDatabaseImplement/Implements/Worker/BuildStorage.cs @@ -15,7 +15,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker return context.Builds .Include(x => x.Purchases) .ThenInclude(x => x.Purchase) - .Include(x => x.User) .ToList() .Select(x => x.GetViewModel) .ToList(); @@ -57,7 +56,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker return context.Builds .Include(x => x.Purchases) .ThenInclude(x => x.Purchase) - .Include(x => x.User) .Where(x => x.Id == model.Id) .FirstOrDefault(x => (!string.IsNullOrEmpty(model.BuildName) && x.BuildName == model.BuildName) || (model.Id.HasValue && x.Id == model.Id)) @@ -77,7 +75,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker return context.Builds .Include(x => x.Purchases) .ThenInclude(x => x.Purchase) - .Include(x => x.User) .Where(x => x.UserId == model.Id) .FirstOrDefault(x => x.Id == newBuild.Id) ?.GetViewModel; @@ -92,7 +89,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker var build = context.Builds .Include(x => x.Purchases) .ThenInclude(x => x.Purchase) - .Include(x => x.User) .Where(x => x.UserId == model.UserId) .FirstOrDefault(x => x.Id == model.Id); if (build == null) @@ -118,7 +114,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker var element = context.Builds .Include(x => x.Purchases) .ThenInclude(x => x.Purchase) - .Include(x => x.User) .Where(x => x.UserId == model.Id) .FirstOrDefault(rec => rec.Id == model.Id); if (element != null) diff --git a/HardwareShop/HardwareShopDatabaseImplement/Implements/Worker/CommentStorage.cs b/HardwareShop/HardwareShopDatabaseImplement/Implements/Worker/CommentStorage.cs index 9812184..cf3df50 100644 --- a/HardwareShop/HardwareShopDatabaseImplement/Implements/Worker/CommentStorage.cs +++ b/HardwareShop/HardwareShopDatabaseImplement/Implements/Worker/CommentStorage.cs @@ -14,7 +14,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker using var context = new HardwareShopDatabase(); return context.Comments .Include(x => x.Build) - .Include(x => x.User) .Select(x => x.GetViewModel) .ToList(); } @@ -30,14 +29,12 @@ namespace HardwareShopDatabaseImplement.Implements.Worker { return context.Comments .Include(x => x.Build) - .Include(x => x.User) .Where(x => x.UserId == model.UserId) .Select(x => x.GetViewModel) .ToList(); } return context.Comments .Include(x => x.Build) - .Include(x => x.User) .Where(x => x.BuildId == model.BuildId) .Select(x => x.GetViewModel) .ToList(); @@ -52,7 +49,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker using var context = new HardwareShopDatabase(); return context.Comments .Include(x => x.Build) - .Include(x => x.User) .FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id) ?.GetViewModel; } @@ -75,7 +71,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker using var context = new HardwareShopDatabase(); var comment = context.Comments .Include(x => x.Build) - .Include(x => x.User) .FirstOrDefault(x => x.Id == model.Id); if (comment == null) { @@ -91,7 +86,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker using var context = new HardwareShopDatabase(); var element = context.Comments .Include(x => x.Build) - .Include(x => x.User) .FirstOrDefault(rec => rec.Id == model.Id); if (element != null) { diff --git a/HardwareShop/HardwareShopDatabaseImplement/Implements/Worker/PurchaseStorage.cs b/HardwareShop/HardwareShopDatabaseImplement/Implements/Worker/PurchaseStorage.cs index cee197b..95b9553 100644 --- a/HardwareShop/HardwareShopDatabaseImplement/Implements/Worker/PurchaseStorage.cs +++ b/HardwareShop/HardwareShopDatabaseImplement/Implements/Worker/PurchaseStorage.cs @@ -17,7 +17,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker return context.Purchases .Include(x => x.Goods) .ThenInclude(x => x.Good) - .Include(x => x.User) .Select(x => x.GetViewModel) .ToList(); } @@ -34,7 +33,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker return context.Purchases .Include(x => x.Goods) .ThenInclude(x => x.Good) - .Include(x => x.User) .Where(x => x.UserId == model.UserId) .Select(x => x.GetViewModel) .ToList(); @@ -42,7 +40,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker return context.Purchases .Include(x => x.Goods) .ThenInclude(x => x.Good) - .Include(x => x.User) .Where(x => x.DatePurchase == model.DatePurchase) .Select(x => x.GetViewModel) .ToList(); @@ -58,7 +55,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker return context.Purchases .Include(x => x.Goods) .ThenInclude(x => x.Good) - .Include(x => x.User) .FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id) ?.GetViewModel; } @@ -76,7 +72,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker return context.Purchases .Include(x => x.Goods) .ThenInclude(x => x.Good) - .Include(x => x.User) .FirstOrDefault(x => x.Id == newPurchase.Id) ?.GetViewModel; } @@ -90,7 +85,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker var purchase = context.Purchases .Include(x => x.Goods) .ThenInclude(x => x.Good) - .Include(x => x.User) .FirstOrDefault(x => x.Id == model.Id); if (purchase == null) { @@ -115,7 +109,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker var element = context.Purchases .Include(x => x.Goods) .ThenInclude(x => x.Good) - .Include(x => x.User) .FirstOrDefault(rec => rec.Id == model.Id); if (element != null) { diff --git a/HardwareShop/HardwareShopDatabaseImplement/Models/Worker/Build.cs b/HardwareShop/HardwareShopDatabaseImplement/Models/Worker/Build.cs index a319b23..812f6ea 100644 --- a/HardwareShop/HardwareShopDatabaseImplement/Models/Worker/Build.cs +++ b/HardwareShop/HardwareShopDatabaseImplement/Models/Worker/Build.cs @@ -70,7 +70,6 @@ namespace HardwareShopDatabaseImplement.Models.Worker Id = Id, BuildName = BuildName, Price = Price, - UserLogin = User.Login, UserId = UserId, BuildPurchases = BuildPurchases, }; @@ -91,7 +90,7 @@ namespace HardwareShopDatabaseImplement.Models.Worker context.SaveChanges(); } var build = context.Builds.First(x => x.Id == Id); - //добавляем в бд элементы которые есть в модели, но ещё нет в бд + //добавляем в бд сборки которые есть в модели, но ещё нет в бд foreach (var bp in model.BuildPurchases) { context.PurchasesBuilds.Add(new PurchaseBuild diff --git a/HardwareShop/HardwareShopDatabaseImplement/Models/Worker/Comment.cs b/HardwareShop/HardwareShopDatabaseImplement/Models/Worker/Comment.cs index 64b74b6..cd529a9 100644 --- a/HardwareShop/HardwareShopDatabaseImplement/Models/Worker/Comment.cs +++ b/HardwareShop/HardwareShopDatabaseImplement/Models/Worker/Comment.cs @@ -52,7 +52,6 @@ namespace HardwareShopDatabaseImplement.Models.Worker BuildId = BuildId, BuildName = Build.BuildName, UserId = UserId, - UserLogin = User.Login, }; } } diff --git a/HardwareShop/HardwareShopDatabaseImplement/Models/Worker/Purchase.cs b/HardwareShop/HardwareShopDatabaseImplement/Models/Worker/Purchase.cs index 35a163f..c7ffc1e 100644 --- a/HardwareShop/HardwareShopDatabaseImplement/Models/Worker/Purchase.cs +++ b/HardwareShop/HardwareShopDatabaseImplement/Models/Worker/Purchase.cs @@ -78,7 +78,6 @@ namespace HardwareShopDatabaseImplement.Models.Worker PurchaseStatus = PurchaseStatus, DatePurchase = DatePurchase, UserId = UserId, - UserLogin = User.Login, PurchaseGoods = PurchaseGoods }; @@ -98,7 +97,7 @@ namespace HardwareShopDatabaseImplement.Models.Worker context.SaveChanges(); } var purchase = context.Purchases.First(x => x.Id == Id); - //добавляем в бд блюда которые есть в моделе, но ещё нет в бд + //добавляем в бд товары которые есть в моделе, но ещё нет в бд foreach (var dc in model.PurchaseGoods) { context.PurchasesGoods.Add(new PurchaseGood