Добавлены связи
This commit is contained in:
@@ -38,7 +38,7 @@ namespace ComputerShopDatabaseImplement.Models
|
||||
[ForeignKey("AssemblyId")]
|
||||
public virtual List<AssemblyComponent> Components { get; set; } = new();
|
||||
[ForeignKey("AssemblyId")]
|
||||
public virtual List<Purchase> Purchases { get; set; } = new();
|
||||
public virtual List<AssemblyOrder> Orders { get; set; } = new();
|
||||
public static Assembly Create(ComputerShopDatabase context, AssemblyBindingModel model)
|
||||
{
|
||||
return new Assembly()
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerShopDatabaseImplement.Models
|
||||
{
|
||||
internal class AssemblyOrder
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public int AssemblyId { get; set; }
|
||||
[Required]
|
||||
public int OrderId { get; set; }
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
public virtual Order Order { get; set; } = new();
|
||||
public virtual Assembly Assembly { get; set; } = new();
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,10 @@ namespace ComputerShopDatabaseImplement.Models
|
||||
[ForeignKey("ComponentId")]
|
||||
public virtual List<AssemblyComponent> AssemblyComponents { get; set; } =
|
||||
new();
|
||||
[ForeignKey("ComponentId")]
|
||||
public virtual List<Purchase> Purchases { get; set; } = new();
|
||||
[ForeignKey("ComponentId")]
|
||||
public virtual List<ComponentSupply> Supplies { get; set; } = new();
|
||||
public static Component? Create(ComponentBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComputerShopDatabaseImplement.Models
|
||||
{
|
||||
internal class ComponentSupply
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public int SupplyId { get; set; }
|
||||
[Required]
|
||||
public int ComponentId { get; set; }
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
public virtual Supply Supply { get; set; } = new();
|
||||
public virtual Component Component { get; set; } = new();
|
||||
}
|
||||
}
|
||||
@@ -24,8 +24,9 @@ namespace ComputerShopDatabaseImplement.Models
|
||||
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
[ForeignKey("OrderId")]
|
||||
public virtual List<SupplyOrder> SupplyOrders { get; set; } =
|
||||
new();
|
||||
public virtual List<SupplyOrder> SupplyOrders { get; set; } = new();
|
||||
[ForeignKey("OrderId")]
|
||||
public virtual List<AssemblyOrder> Assemblies { get; set; } = new();
|
||||
public static Order? Create(OrderBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
|
||||
@@ -46,7 +46,9 @@ namespace ComputerShopDatabaseImplement.Models
|
||||
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 static Supply Create(ComputerShopDatabase context, SupplyBindingModel model)
|
||||
{
|
||||
return new Supply
|
||||
|
||||
Reference in New Issue
Block a user