удаление лишних инклудов
This commit is contained in:
parent
5c849f7d59
commit
76c9fa6580
@ -12,9 +12,6 @@ namespace HardwareShopContracts.ViewModels
|
|||||||
[DisplayName("Название Сборки")]
|
[DisplayName("Название Сборки")]
|
||||||
public string BuildName { get; set; } = string.Empty;
|
public string BuildName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Логин пользователя")]
|
|
||||||
public string UserLogin { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public int UserId { get; set; }
|
public int UserId { get; set; }
|
||||||
|
|
||||||
public Dictionary<int, (IPurchaseModel, int)> BuildPurchases { get; set; } = new();
|
public Dictionary<int, (IPurchaseModel, int)> BuildPurchases { get; set; } = new();
|
||||||
|
@ -16,8 +16,5 @@ namespace HardwareShopContracts.ViewModels
|
|||||||
public int BuildId { get; set; }
|
public int BuildId { get; set; }
|
||||||
|
|
||||||
public int UserId { get; set; }
|
public int UserId { get; set; }
|
||||||
|
|
||||||
[DisplayName("Логин пользователя")]
|
|
||||||
public string UserLogin { get; set; } = string.Empty;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,6 @@ namespace HardwareShopContracts.ViewModels
|
|||||||
|
|
||||||
public int UserId { get; set; }
|
public int UserId { get; set; }
|
||||||
|
|
||||||
[DisplayName("Логин пользователя")]
|
|
||||||
public string UserLogin { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public Dictionary<int, (IGoodModel, int)> PurchaseGoods { get; set; } = new();
|
public Dictionary<int, (IGoodModel, int)> PurchaseGoods { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
|
|||||||
return context.Builds
|
return context.Builds
|
||||||
.Include(x => x.Purchases)
|
.Include(x => x.Purchases)
|
||||||
.ThenInclude(x => x.Purchase)
|
.ThenInclude(x => x.Purchase)
|
||||||
.Include(x => x.User)
|
|
||||||
.ToList()
|
.ToList()
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
@ -57,7 +56,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
|
|||||||
return context.Builds
|
return context.Builds
|
||||||
.Include(x => x.Purchases)
|
.Include(x => x.Purchases)
|
||||||
.ThenInclude(x => x.Purchase)
|
.ThenInclude(x => x.Purchase)
|
||||||
.Include(x => x.User)
|
|
||||||
.Where(x => x.Id == model.Id)
|
.Where(x => x.Id == model.Id)
|
||||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.BuildName) && x.BuildName == model.BuildName) ||
|
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.BuildName) && x.BuildName == model.BuildName) ||
|
||||||
(model.Id.HasValue && x.Id == model.Id))
|
(model.Id.HasValue && x.Id == model.Id))
|
||||||
@ -77,7 +75,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
|
|||||||
return context.Builds
|
return context.Builds
|
||||||
.Include(x => x.Purchases)
|
.Include(x => x.Purchases)
|
||||||
.ThenInclude(x => x.Purchase)
|
.ThenInclude(x => x.Purchase)
|
||||||
.Include(x => x.User)
|
|
||||||
.Where(x => x.UserId == model.Id)
|
.Where(x => x.UserId == model.Id)
|
||||||
.FirstOrDefault(x => x.Id == newBuild.Id)
|
.FirstOrDefault(x => x.Id == newBuild.Id)
|
||||||
?.GetViewModel;
|
?.GetViewModel;
|
||||||
@ -92,7 +89,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
|
|||||||
var build = context.Builds
|
var build = context.Builds
|
||||||
.Include(x => x.Purchases)
|
.Include(x => x.Purchases)
|
||||||
.ThenInclude(x => x.Purchase)
|
.ThenInclude(x => x.Purchase)
|
||||||
.Include(x => x.User)
|
|
||||||
.Where(x => x.UserId == model.UserId)
|
.Where(x => x.UserId == model.UserId)
|
||||||
.FirstOrDefault(x => x.Id == model.Id);
|
.FirstOrDefault(x => x.Id == model.Id);
|
||||||
if (build == null)
|
if (build == null)
|
||||||
@ -118,7 +114,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
|
|||||||
var element = context.Builds
|
var element = context.Builds
|
||||||
.Include(x => x.Purchases)
|
.Include(x => x.Purchases)
|
||||||
.ThenInclude(x => x.Purchase)
|
.ThenInclude(x => x.Purchase)
|
||||||
.Include(x => x.User)
|
|
||||||
.Where(x => x.UserId == model.Id)
|
.Where(x => x.UserId == model.Id)
|
||||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
if (element != null)
|
if (element != null)
|
||||||
|
@ -14,7 +14,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
|
|||||||
using var context = new HardwareShopDatabase();
|
using var context = new HardwareShopDatabase();
|
||||||
return context.Comments
|
return context.Comments
|
||||||
.Include(x => x.Build)
|
.Include(x => x.Build)
|
||||||
.Include(x => x.User)
|
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
@ -30,14 +29,12 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
|
|||||||
{
|
{
|
||||||
return context.Comments
|
return context.Comments
|
||||||
.Include(x => x.Build)
|
.Include(x => x.Build)
|
||||||
.Include(x => x.User)
|
|
||||||
.Where(x => x.UserId == model.UserId)
|
.Where(x => x.UserId == model.UserId)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
return context.Comments
|
return context.Comments
|
||||||
.Include(x => x.Build)
|
.Include(x => x.Build)
|
||||||
.Include(x => x.User)
|
|
||||||
.Where(x => x.BuildId == model.BuildId)
|
.Where(x => x.BuildId == model.BuildId)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
@ -52,7 +49,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
|
|||||||
using var context = new HardwareShopDatabase();
|
using var context = new HardwareShopDatabase();
|
||||||
return context.Comments
|
return context.Comments
|
||||||
.Include(x => x.Build)
|
.Include(x => x.Build)
|
||||||
.Include(x => x.User)
|
|
||||||
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
||||||
?.GetViewModel;
|
?.GetViewModel;
|
||||||
}
|
}
|
||||||
@ -75,7 +71,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
|
|||||||
using var context = new HardwareShopDatabase();
|
using var context = new HardwareShopDatabase();
|
||||||
var comment = context.Comments
|
var comment = context.Comments
|
||||||
.Include(x => x.Build)
|
.Include(x => x.Build)
|
||||||
.Include(x => x.User)
|
|
||||||
.FirstOrDefault(x => x.Id == model.Id);
|
.FirstOrDefault(x => x.Id == model.Id);
|
||||||
if (comment == null)
|
if (comment == null)
|
||||||
{
|
{
|
||||||
@ -91,7 +86,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
|
|||||||
using var context = new HardwareShopDatabase();
|
using var context = new HardwareShopDatabase();
|
||||||
var element = context.Comments
|
var element = context.Comments
|
||||||
.Include(x => x.Build)
|
.Include(x => x.Build)
|
||||||
.Include(x => x.User)
|
|
||||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
if (element != null)
|
if (element != null)
|
||||||
{
|
{
|
||||||
|
@ -17,7 +17,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
|
|||||||
return context.Purchases
|
return context.Purchases
|
||||||
.Include(x => x.Goods)
|
.Include(x => x.Goods)
|
||||||
.ThenInclude(x => x.Good)
|
.ThenInclude(x => x.Good)
|
||||||
.Include(x => x.User)
|
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
@ -34,7 +33,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
|
|||||||
return context.Purchases
|
return context.Purchases
|
||||||
.Include(x => x.Goods)
|
.Include(x => x.Goods)
|
||||||
.ThenInclude(x => x.Good)
|
.ThenInclude(x => x.Good)
|
||||||
.Include(x => x.User)
|
|
||||||
.Where(x => x.UserId == model.UserId)
|
.Where(x => x.UserId == model.UserId)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
@ -42,7 +40,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
|
|||||||
return context.Purchases
|
return context.Purchases
|
||||||
.Include(x => x.Goods)
|
.Include(x => x.Goods)
|
||||||
.ThenInclude(x => x.Good)
|
.ThenInclude(x => x.Good)
|
||||||
.Include(x => x.User)
|
|
||||||
.Where(x => x.DatePurchase == model.DatePurchase)
|
.Where(x => x.DatePurchase == model.DatePurchase)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
@ -58,7 +55,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
|
|||||||
return context.Purchases
|
return context.Purchases
|
||||||
.Include(x => x.Goods)
|
.Include(x => x.Goods)
|
||||||
.ThenInclude(x => x.Good)
|
.ThenInclude(x => x.Good)
|
||||||
.Include(x => x.User)
|
|
||||||
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
||||||
?.GetViewModel;
|
?.GetViewModel;
|
||||||
}
|
}
|
||||||
@ -76,7 +72,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
|
|||||||
return context.Purchases
|
return context.Purchases
|
||||||
.Include(x => x.Goods)
|
.Include(x => x.Goods)
|
||||||
.ThenInclude(x => x.Good)
|
.ThenInclude(x => x.Good)
|
||||||
.Include(x => x.User)
|
|
||||||
.FirstOrDefault(x => x.Id == newPurchase.Id)
|
.FirstOrDefault(x => x.Id == newPurchase.Id)
|
||||||
?.GetViewModel;
|
?.GetViewModel;
|
||||||
}
|
}
|
||||||
@ -90,7 +85,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
|
|||||||
var purchase = context.Purchases
|
var purchase = context.Purchases
|
||||||
.Include(x => x.Goods)
|
.Include(x => x.Goods)
|
||||||
.ThenInclude(x => x.Good)
|
.ThenInclude(x => x.Good)
|
||||||
.Include(x => x.User)
|
|
||||||
.FirstOrDefault(x => x.Id == model.Id);
|
.FirstOrDefault(x => x.Id == model.Id);
|
||||||
if (purchase == null)
|
if (purchase == null)
|
||||||
{
|
{
|
||||||
@ -115,7 +109,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
|
|||||||
var element = context.Purchases
|
var element = context.Purchases
|
||||||
.Include(x => x.Goods)
|
.Include(x => x.Goods)
|
||||||
.ThenInclude(x => x.Good)
|
.ThenInclude(x => x.Good)
|
||||||
.Include(x => x.User)
|
|
||||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
if (element != null)
|
if (element != null)
|
||||||
{
|
{
|
||||||
|
@ -70,7 +70,6 @@ namespace HardwareShopDatabaseImplement.Models.Worker
|
|||||||
Id = Id,
|
Id = Id,
|
||||||
BuildName = BuildName,
|
BuildName = BuildName,
|
||||||
Price = Price,
|
Price = Price,
|
||||||
UserLogin = User.Login,
|
|
||||||
UserId = UserId,
|
UserId = UserId,
|
||||||
BuildPurchases = BuildPurchases,
|
BuildPurchases = BuildPurchases,
|
||||||
};
|
};
|
||||||
@ -91,7 +90,7 @@ namespace HardwareShopDatabaseImplement.Models.Worker
|
|||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
}
|
}
|
||||||
var build = context.Builds.First(x => x.Id == Id);
|
var build = context.Builds.First(x => x.Id == Id);
|
||||||
//добавляем в бд элементы которые есть в модели, но ещё нет в бд
|
//добавляем в бд сборки которые есть в модели, но ещё нет в бд
|
||||||
foreach (var bp in model.BuildPurchases)
|
foreach (var bp in model.BuildPurchases)
|
||||||
{
|
{
|
||||||
context.PurchasesBuilds.Add(new PurchaseBuild
|
context.PurchasesBuilds.Add(new PurchaseBuild
|
||||||
|
@ -52,7 +52,6 @@ namespace HardwareShopDatabaseImplement.Models.Worker
|
|||||||
BuildId = BuildId,
|
BuildId = BuildId,
|
||||||
BuildName = Build.BuildName,
|
BuildName = Build.BuildName,
|
||||||
UserId = UserId,
|
UserId = UserId,
|
||||||
UserLogin = User.Login,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,6 @@ namespace HardwareShopDatabaseImplement.Models.Worker
|
|||||||
PurchaseStatus = PurchaseStatus,
|
PurchaseStatus = PurchaseStatus,
|
||||||
DatePurchase = DatePurchase,
|
DatePurchase = DatePurchase,
|
||||||
UserId = UserId,
|
UserId = UserId,
|
||||||
UserLogin = User.Login,
|
|
||||||
PurchaseGoods = PurchaseGoods
|
PurchaseGoods = PurchaseGoods
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -98,7 +97,7 @@ namespace HardwareShopDatabaseImplement.Models.Worker
|
|||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
}
|
}
|
||||||
var purchase = context.Purchases.First(x => x.Id == Id);
|
var purchase = context.Purchases.First(x => x.Id == Id);
|
||||||
//добавляем в бд блюда которые есть в моделе, но ещё нет в бд
|
//добавляем в бд товары которые есть в моделе, но ещё нет в бд
|
||||||
foreach (var dc in model.PurchaseGoods)
|
foreach (var dc in model.PurchaseGoods)
|
||||||
{
|
{
|
||||||
context.PurchasesGoods.Add(new PurchaseGood
|
context.PurchasesGoods.Add(new PurchaseGood
|
||||||
|
Loading…
Reference in New Issue
Block a user