Лишние инклуды
This commit is contained in:
parent
0a57d3ebf3
commit
ea30411791
@ -11,8 +11,6 @@ namespace HardwareShopContracts.ViewModels
|
|||||||
[DisplayName("Цена")]
|
[DisplayName("Цена")]
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
public int UserId { get; set; }
|
public int UserId { get; set; }
|
||||||
[DisplayName("Логин кладовщика")]
|
|
||||||
public string UserLogin { get; set; } = string.Empty;
|
|
||||||
public Dictionary<int, (IBuildModel, int)>? ComponentsBuilds
|
public Dictionary<int, (IBuildModel, int)>? ComponentsBuilds
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
|
@ -11,8 +11,6 @@ namespace HardwareShopContracts.ViewModels
|
|||||||
[DisplayName("Цена")]
|
[DisplayName("Цена")]
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
public int UserId { get; set; }
|
public int UserId { get; set; }
|
||||||
[DisplayName("Логин кладовщика")]
|
|
||||||
public string UserLogin { get; set; } = string.Empty;
|
|
||||||
public Dictionary<int, (IComponentModel, int)> GoodsComponents
|
public Dictionary<int, (IComponentModel, int)> GoodsComponents
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
|
@ -10,8 +10,6 @@ namespace HardwareShopContracts.ViewModels
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public int GoodId { get; set; }
|
public int GoodId { get; set; }
|
||||||
public int UserId { get; set; }
|
public int UserId { get; set; }
|
||||||
[DisplayName("Логин кладовщика")]
|
|
||||||
public string UserLogin { get; set; } = string.Empty;
|
|
||||||
[DisplayName("Товар")]
|
[DisplayName("Товар")]
|
||||||
public string GoodName { get; set; } = string.Empty;
|
public string GoodName { get; set; } = string.Empty;
|
||||||
[DisplayName("Количество")]
|
[DisplayName("Количество")]
|
||||||
|
@ -13,7 +13,6 @@ namespace HardwareShopDatabaseImplement.Implements.Storekeeper
|
|||||||
{
|
{
|
||||||
using var context = new HardwareShopDatabase();
|
using var context = new HardwareShopDatabase();
|
||||||
var element = context.Components
|
var element = context.Components
|
||||||
.Include(x => x.User)
|
|
||||||
.Include(x => x.Builds)
|
.Include(x => x.Builds)
|
||||||
.ThenInclude(x => x.Build)
|
.ThenInclude(x => x.Build)
|
||||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
@ -31,14 +30,12 @@ namespace HardwareShopDatabaseImplement.Implements.Storekeeper
|
|||||||
using var context = new HardwareShopDatabase();
|
using var context = new HardwareShopDatabase();
|
||||||
if (!string.IsNullOrEmpty(model.ComponentName) || model.Id.HasValue)
|
if (!string.IsNullOrEmpty(model.ComponentName) || model.Id.HasValue)
|
||||||
return context.Components
|
return context.Components
|
||||||
.Include(x => x.User)
|
|
||||||
.Include(x => x.Builds)
|
.Include(x => x.Builds)
|
||||||
.ThenInclude(x => x.Build)
|
.ThenInclude(x => x.Build)
|
||||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ComponentName)
|
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ComponentName)
|
||||||
&& x.ComponentName == model.ComponentName) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
&& x.ComponentName == model.ComponentName) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||||
if (model.UserId.HasValue)
|
if (model.UserId.HasValue)
|
||||||
return context.Components
|
return context.Components
|
||||||
.Include(x => x.User)
|
|
||||||
.Include(x => x.Builds)
|
.Include(x => x.Builds)
|
||||||
.ThenInclude(x => x.Build)
|
.ThenInclude(x => x.Build)
|
||||||
.FirstOrDefault(x => x.UserId == model.UserId)?.GetViewModel;
|
.FirstOrDefault(x => x.UserId == model.UserId)?.GetViewModel;
|
||||||
@ -51,7 +48,6 @@ namespace HardwareShopDatabaseImplement.Implements.Storekeeper
|
|||||||
if (model.UserId.HasValue)
|
if (model.UserId.HasValue)
|
||||||
{
|
{
|
||||||
return context.Components
|
return context.Components
|
||||||
.Include(x => x.User)
|
|
||||||
.Include(x => x.Builds)
|
.Include(x => x.Builds)
|
||||||
.ThenInclude(x => x.Build)
|
.ThenInclude(x => x.Build)
|
||||||
.Where(x => x.UserId == model.UserId)
|
.Where(x => x.UserId == model.UserId)
|
||||||
@ -61,7 +57,6 @@ namespace HardwareShopDatabaseImplement.Implements.Storekeeper
|
|||||||
if (!string.IsNullOrEmpty(model.ComponentName))
|
if (!string.IsNullOrEmpty(model.ComponentName))
|
||||||
{
|
{
|
||||||
return context.Components
|
return context.Components
|
||||||
.Include(x => x.User)
|
|
||||||
.Include(x => x.Builds)
|
.Include(x => x.Builds)
|
||||||
.ThenInclude(x => x.Build)
|
.ThenInclude(x => x.Build)
|
||||||
.Where(x => x.ComponentName.Contains(model.ComponentName))
|
.Where(x => x.ComponentName.Contains(model.ComponentName))
|
||||||
@ -75,7 +70,6 @@ namespace HardwareShopDatabaseImplement.Implements.Storekeeper
|
|||||||
{
|
{
|
||||||
using var context = new HardwareShopDatabase();
|
using var context = new HardwareShopDatabase();
|
||||||
return context.Components
|
return context.Components
|
||||||
.Include(x => x.User)
|
|
||||||
.Include(x => x.Builds)
|
.Include(x => x.Builds)
|
||||||
.ThenInclude(x => x.Build)
|
.ThenInclude(x => x.Build)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
@ -93,7 +87,6 @@ namespace HardwareShopDatabaseImplement.Implements.Storekeeper
|
|||||||
context.Components.Add(newComponent);
|
context.Components.Add(newComponent);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
return context.Components
|
return context.Components
|
||||||
.Include(x => x.User)
|
|
||||||
.Include(x => x.Builds)
|
.Include(x => x.Builds)
|
||||||
.ThenInclude(x => x.Build)
|
.ThenInclude(x => x.Build)
|
||||||
.FirstOrDefault(x => x.Id == newComponent.Id)?.GetViewModel;
|
.FirstOrDefault(x => x.Id == newComponent.Id)?.GetViewModel;
|
||||||
@ -106,7 +99,6 @@ namespace HardwareShopDatabaseImplement.Implements.Storekeeper
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var good = context.Components
|
var good = context.Components
|
||||||
.Include(x => x.User)
|
|
||||||
.Include(x => x.Builds)
|
.Include(x => x.Builds)
|
||||||
.ThenInclude(x => x.Build)
|
.ThenInclude(x => x.Build)
|
||||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
@ -13,7 +13,6 @@ namespace HardwareShopDatabaseImplement.Implements.Storekeeper
|
|||||||
{
|
{
|
||||||
using var context = new HardwareShopDatabase();
|
using var context = new HardwareShopDatabase();
|
||||||
var element = context.Goods
|
var element = context.Goods
|
||||||
.Include(x => x.User)
|
|
||||||
.Include(x => x.Components)
|
.Include(x => x.Components)
|
||||||
.ThenInclude(x => x.Component)
|
.ThenInclude(x => x.Component)
|
||||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
@ -31,14 +30,12 @@ namespace HardwareShopDatabaseImplement.Implements.Storekeeper
|
|||||||
using var context = new HardwareShopDatabase();
|
using var context = new HardwareShopDatabase();
|
||||||
if (model.UserId.HasValue)
|
if (model.UserId.HasValue)
|
||||||
return context.Goods
|
return context.Goods
|
||||||
.Include(x => x.User)
|
|
||||||
.Include(x => x.Components)
|
.Include(x => x.Components)
|
||||||
.ThenInclude(x => x.Component)
|
.ThenInclude(x => x.Component)
|
||||||
.FirstOrDefault(x => x.UserId == model.UserId)
|
.FirstOrDefault(x => x.UserId == model.UserId)
|
||||||
?.GetViewModel;
|
?.GetViewModel;
|
||||||
if (!string.IsNullOrEmpty(model.GoodName) || model.Id.HasValue)
|
if (!string.IsNullOrEmpty(model.GoodName) || model.Id.HasValue)
|
||||||
return context.Goods
|
return context.Goods
|
||||||
.Include(x => x.User)
|
|
||||||
.Include(x => x.Components)
|
.Include(x => x.Components)
|
||||||
.ThenInclude(x => x.Component)
|
.ThenInclude(x => x.Component)
|
||||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.GoodName) && x.GoodName == model.GoodName) ||
|
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.GoodName) && x.GoodName == model.GoodName) ||
|
||||||
@ -52,7 +49,6 @@ namespace HardwareShopDatabaseImplement.Implements.Storekeeper
|
|||||||
using var context = new HardwareShopDatabase();
|
using var context = new HardwareShopDatabase();
|
||||||
if (model.UserId.HasValue)
|
if (model.UserId.HasValue)
|
||||||
return context.Goods
|
return context.Goods
|
||||||
.Include(x => x.User)
|
|
||||||
.Include(x => x.Components)
|
.Include(x => x.Components)
|
||||||
.ThenInclude(x => x.Component)
|
.ThenInclude(x => x.Component)
|
||||||
.Where(x => x.UserId == model.UserId)
|
.Where(x => x.UserId == model.UserId)
|
||||||
@ -60,7 +56,6 @@ namespace HardwareShopDatabaseImplement.Implements.Storekeeper
|
|||||||
.ToList();
|
.ToList();
|
||||||
if (!string.IsNullOrEmpty(model.GoodName))
|
if (!string.IsNullOrEmpty(model.GoodName))
|
||||||
return context.Goods
|
return context.Goods
|
||||||
.Include(x => x.User)
|
|
||||||
.Include(x => x.Components)
|
.Include(x => x.Components)
|
||||||
.ThenInclude(x => x.Component)
|
.ThenInclude(x => x.Component)
|
||||||
.Where(x => x.GoodName.Contains(model.GoodName))
|
.Where(x => x.GoodName.Contains(model.GoodName))
|
||||||
@ -73,7 +68,6 @@ namespace HardwareShopDatabaseImplement.Implements.Storekeeper
|
|||||||
{
|
{
|
||||||
using var context = new HardwareShopDatabase();
|
using var context = new HardwareShopDatabase();
|
||||||
return context.Goods
|
return context.Goods
|
||||||
.Include(x => x.User)
|
|
||||||
.Include(x => x.Components)
|
.Include(x => x.Components)
|
||||||
.ThenInclude(x => x.Component)
|
.ThenInclude(x => x.Component)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
@ -91,7 +85,6 @@ namespace HardwareShopDatabaseImplement.Implements.Storekeeper
|
|||||||
context.Goods.Add(newGood);
|
context.Goods.Add(newGood);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
return context.Goods
|
return context.Goods
|
||||||
.Include(x => x.User)
|
|
||||||
.Include(x => x.Components)
|
.Include(x => x.Components)
|
||||||
.ThenInclude(x => x.Component)
|
.ThenInclude(x => x.Component)
|
||||||
.FirstOrDefault(x => x.Id == newGood.Id)?.GetViewModel;
|
.FirstOrDefault(x => x.Id == newGood.Id)?.GetViewModel;
|
||||||
@ -104,7 +97,6 @@ namespace HardwareShopDatabaseImplement.Implements.Storekeeper
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var good = context.Goods
|
var good = context.Goods
|
||||||
.Include(x => x.User)
|
|
||||||
.Include(x => x.Components)
|
.Include(x => x.Components)
|
||||||
.ThenInclude(x => x.Component)
|
.ThenInclude(x => x.Component)
|
||||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
@ -13,7 +13,7 @@ namespace HardwareShopDatabaseImplement.Implements.Storekeeper
|
|||||||
{
|
{
|
||||||
using var context = new HardwareShopDatabase();
|
using var context = new HardwareShopDatabase();
|
||||||
var element = context.Orders
|
var element = context.Orders
|
||||||
.Include(x => x.Good).Include(x => x.User)
|
.Include(x => x.Good)
|
||||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
if (element != null)
|
if (element != null)
|
||||||
{
|
{
|
||||||
@ -32,7 +32,7 @@ namespace HardwareShopDatabaseImplement.Implements.Storekeeper
|
|||||||
}
|
}
|
||||||
using var context = new HardwareShopDatabase();
|
using var context = new HardwareShopDatabase();
|
||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Good).Include(x => x.User)
|
.Include(x => x.Good)
|
||||||
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
||||||
?.GetViewModel;
|
?.GetViewModel;
|
||||||
}
|
}
|
||||||
@ -45,7 +45,7 @@ namespace HardwareShopDatabaseImplement.Implements.Storekeeper
|
|||||||
}
|
}
|
||||||
using var context = new HardwareShopDatabase();
|
using var context = new HardwareShopDatabase();
|
||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Good).Include(x => x.User)
|
.Include(x => x.Good)
|
||||||
.Where(x => x.Id == model.Id)
|
.Where(x => x.Id == model.Id)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
@ -55,7 +55,7 @@ namespace HardwareShopDatabaseImplement.Implements.Storekeeper
|
|||||||
{
|
{
|
||||||
using var context = new HardwareShopDatabase();
|
using var context = new HardwareShopDatabase();
|
||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Good).Include(x => x.User)
|
.Include(x => x.Good)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
@ -71,7 +71,7 @@ namespace HardwareShopDatabaseImplement.Implements.Storekeeper
|
|||||||
context.Orders.Add(newOrder);
|
context.Orders.Add(newOrder);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Good).Include(x => x.User)
|
.Include(x => x.Good)
|
||||||
.FirstOrDefault(x => x.Id == newOrder.Id)
|
.FirstOrDefault(x => x.Id == newOrder.Id)
|
||||||
?.GetViewModel;
|
?.GetViewModel;
|
||||||
}
|
}
|
||||||
@ -80,7 +80,7 @@ namespace HardwareShopDatabaseImplement.Implements.Storekeeper
|
|||||||
{
|
{
|
||||||
using var context = new HardwareShopDatabase();
|
using var context = new HardwareShopDatabase();
|
||||||
var order = context.Orders
|
var order = context.Orders
|
||||||
.Include(x => x.Good).Include(x => x.User)
|
.Include(x => x.Good)
|
||||||
.FirstOrDefault(x => x.Id == model.Id);
|
.FirstOrDefault(x => x.Id == model.Id);
|
||||||
if (order == null)
|
if (order == null)
|
||||||
{
|
{
|
||||||
|
@ -27,8 +27,6 @@ namespace HardwareShopDatabaseImplement.Models.Storekeeper
|
|||||||
[ForeignKey("ComponentId")]
|
[ForeignKey("ComponentId")]
|
||||||
public virtual List<ComponentBuild> Builds { get; set; } = new();
|
public virtual List<ComponentBuild> Builds { get; set; } = new();
|
||||||
|
|
||||||
public virtual User User { get; set; } = null!;
|
|
||||||
|
|
||||||
private Dictionary<int, (IBuildModel, int)>? _componentsBuilds = null;
|
private Dictionary<int, (IBuildModel, int)>? _componentsBuilds = null;
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
@ -76,7 +74,6 @@ namespace HardwareShopDatabaseImplement.Models.Storekeeper
|
|||||||
ComponentName = ComponentName,
|
ComponentName = ComponentName,
|
||||||
Cost = Cost,
|
Cost = Cost,
|
||||||
UserId = UserId,
|
UserId = UserId,
|
||||||
UserLogin = User.Login,
|
|
||||||
ComponentsBuilds = ComponentsBuilds
|
ComponentsBuilds = ComponentsBuilds
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -20,8 +20,6 @@ namespace HardwareShopDatabaseImplement.Models.Storekeeper
|
|||||||
[Required]
|
[Required]
|
||||||
public int UserId { get; set; }
|
public int UserId { get; set; }
|
||||||
|
|
||||||
public virtual User User { get; set; } = null!;
|
|
||||||
|
|
||||||
private Dictionary<int, (IComponentModel, int)>? _goodsComponents = null;
|
private Dictionary<int, (IComponentModel, int)>? _goodsComponents = null;
|
||||||
|
|
||||||
[ForeignKey("GoodId")]
|
[ForeignKey("GoodId")]
|
||||||
@ -79,7 +77,6 @@ namespace HardwareShopDatabaseImplement.Models.Storekeeper
|
|||||||
GoodName = GoodName,
|
GoodName = GoodName,
|
||||||
Price = Price,
|
Price = Price,
|
||||||
UserId = UserId,
|
UserId = UserId,
|
||||||
UserLogin = User.Login,
|
|
||||||
GoodsComponents = GoodsComponents
|
GoodsComponents = GoodsComponents
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -30,8 +30,6 @@ namespace HardwareShopDatabaseImplement.Models.Storekeeper
|
|||||||
|
|
||||||
public DateTime? DateImplement { get; set; }
|
public DateTime? DateImplement { get; set; }
|
||||||
|
|
||||||
public virtual User User { get; set; } = null!;
|
|
||||||
|
|
||||||
public virtual Good Good { get; set; } = null!;
|
public virtual Good Good { get; set; } = null!;
|
||||||
|
|
||||||
public static Order? Create(OrderBindingModel? model)
|
public static Order? Create(OrderBindingModel? model)
|
||||||
@ -73,8 +71,7 @@ namespace HardwareShopDatabaseImplement.Models.Storekeeper
|
|||||||
Status = Status,
|
Status = Status,
|
||||||
DateCreate = DateCreate,
|
DateCreate = DateCreate,
|
||||||
DateImplement = DateImplement,
|
DateImplement = DateImplement,
|
||||||
GoodName = Good.GoodName,
|
GoodName = Good.GoodName
|
||||||
UserLogin = User.Login
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user