Supply fix
This commit is contained in:
@@ -36,6 +36,22 @@ namespace ComputerShopDatabaseImplement.Models
|
||||
return _assemblyComponents;
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<int, (IOrderModel, int)>? _assemblyOrders = null;
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IOrderModel, int)> AssemblyOrders
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_assemblyOrders == null)
|
||||
{
|
||||
_assemblyOrders = Orders
|
||||
.ToDictionary(recPC => recPC.OrderId, recPC =>
|
||||
(recPC.Order as IOrderModel, recPC.Count));
|
||||
}
|
||||
return _assemblyOrders;
|
||||
}
|
||||
}
|
||||
[ForeignKey("AssemblyId")]
|
||||
public virtual List<AssemblyComponent> Components { get; set; } = new();
|
||||
[ForeignKey("AssemblyId")]
|
||||
@@ -54,6 +70,12 @@ namespace ComputerShopDatabaseImplement.Models
|
||||
{
|
||||
Component = context.Components.First(y => y.Id == x.Key),
|
||||
Count = x.Value.Item2
|
||||
}).ToList(),
|
||||
Orders = model.AssemblyOrders.Select(x => new
|
||||
AssemblyOrder
|
||||
{
|
||||
Order = context.Orders.First(y => y.Id == x.Key),
|
||||
Count = x.Value.Item2
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
@@ -68,6 +90,7 @@ namespace ComputerShopDatabaseImplement.Models
|
||||
AssemblyName = AssemblyName,
|
||||
Price = Price,
|
||||
AssemblyComponents = AssemblyComponents,
|
||||
AssemblyOrders = AssemblyOrders,
|
||||
ClientId = ClientId
|
||||
};
|
||||
public void UpdateComponents(ComputerShopDatabase context, AssemblyBindingModel model)
|
||||
|
||||
@@ -5,6 +5,7 @@ using ComputerShopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -19,6 +20,9 @@ namespace ComputerShopDatabaseImplement.Models
|
||||
public int Id { get; set; }
|
||||
public EquipmentReceivingStatus Status { get; private set; } = EquipmentReceivingStatus.Неизвестен;
|
||||
|
||||
[ForeignKey("ReceivingId")]
|
||||
public List<Supply> Supplies { get; set; } = new();
|
||||
|
||||
public static EquipmentReceiving? Create(EquipmentReceivingBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace ComputerShopDatabaseImplement.Models
|
||||
public int OrderId { get; set; }
|
||||
|
||||
public int ReceivingId { get; set; }
|
||||
private Dictionary<int, (int, IOrderModel)>? _supplyOrders =
|
||||
private Dictionary<int, (IOrderModel, int)>? _supplyOrders =
|
||||
null;
|
||||
[NotMapped]
|
||||
public Dictionary<int, (int, IOrderModel)> SupplyOrders
|
||||
@@ -45,9 +45,7 @@ namespace ComputerShopDatabaseImplement.Models
|
||||
[ForeignKey("SupplyId")]
|
||||
public virtual List<SupplyOrder> Orders { get; set; } = new();
|
||||
[ForeignKey("SupplyId")]
|
||||
public virtual List<EquipmentReceiving> Receivings { get; set; } = new();
|
||||
[ForeignKey("SupplyId")]
|
||||
public virtual List<ComponentSupply> Supplies { get; set; } = new();
|
||||
public virtual List<ComponentSupply> ComponentSupplies { get; set; } = new();
|
||||
|
||||
public static Supply Create(ComputerShopDatabase context, SupplyBindingModel model)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user