поиск сборок по продукту
This commit is contained in:
parent
80f5b2fde7
commit
c229b58d9d
@ -4,7 +4,7 @@
|
|||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
public string? Name { get; set; }
|
public string? Name { get; set; }
|
||||||
public int VendorId { get; set; }
|
public int StoreKeeperId { get; set; }
|
||||||
public List<int>? Builds { get; set; }
|
public int? BuildId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
{
|
{
|
||||||
string Name { get; }
|
string Name { get; }
|
||||||
double Price { get; }
|
double Price { get; }
|
||||||
|
int StoreKeeperId { get; }
|
||||||
public Dictionary<int, (IComponentModel, int)> ProductComponents { get; }
|
public Dictionary<int, (IComponentModel, int)> ProductComponents { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,13 @@ namespace ComputerHardwareStoreDatabaseImplement.Implements
|
|||||||
}
|
}
|
||||||
using var context = new ComputerHardwareStoreDBContext();
|
using var context = new ComputerHardwareStoreDBContext();
|
||||||
return context.Products
|
return context.Products
|
||||||
.Where(p => p.Name.Contains(model.Name))
|
.Where(p => (p.StoreKeeperId == model.StoreKeeperId)
|
||||||
|
// есть хотя бы 1 общий со сборкой компонент
|
||||||
|
&& (!model.BuildId.HasValue || p.Components.FirstOrDefault
|
||||||
|
(c => c.Component.BuldComponents.FirstOrDefault(
|
||||||
|
b => b.BuildId == model.BuildId)
|
||||||
|
!= null)
|
||||||
|
!= null))
|
||||||
.Include(p => p.Components)
|
.Include(p => p.Components)
|
||||||
.ThenInclude(p => p.Component)
|
.ThenInclude(p => p.Component)
|
||||||
.Select(p => p.GetViewModel)
|
.Select(p => p.GetViewModel)
|
||||||
|
@ -20,6 +20,8 @@ namespace ComputerHardwareStoreDatabaseImplement.Models
|
|||||||
|
|
||||||
[ForeignKey("ComponentId")]
|
[ForeignKey("ComponentId")]
|
||||||
public virtual List<ProductComponent> ProductComponents { get; set; } = new();
|
public virtual List<ProductComponent> ProductComponents { get; set; } = new();
|
||||||
|
[ForeignKey("ComponentId")]
|
||||||
|
public virtual List<BuildComponent> BuldComponents { get; set; } = new();
|
||||||
public static Component? Create(ComponentBindingModel model)
|
public static Component? Create(ComponentBindingModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
|
@ -14,6 +14,7 @@ namespace ComputerHardwareStoreDatabaseImplement.Models
|
|||||||
public string Name { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
[Required]
|
[Required]
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
|
public int StoreKeeperId { get; private set; }
|
||||||
private Dictionary<int, (IComponentModel, int)>? _productComponents = null;
|
private Dictionary<int, (IComponentModel, int)>? _productComponents = null;
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public Dictionary<int, (IComponentModel, int)> ProductComponents
|
public Dictionary<int, (IComponentModel, int)> ProductComponents
|
||||||
|
Loading…
Reference in New Issue
Block a user