word
This commit is contained in:
parent
dc3dab57ba
commit
92235ba186
@ -10,6 +10,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ComputerShopDataModels.Enums;
|
||||
|
||||
namespace ComputerShopBusinessLogic.BusinessLogics
|
||||
{
|
||||
@ -37,7 +38,10 @@ namespace ComputerShopBusinessLogic.BusinessLogics
|
||||
public List<ReportComponentReceivingViewModel> GetComponentReceivings(List<int> ids)
|
||||
{
|
||||
var result = new List<ReportComponentReceivingViewModel>();
|
||||
|
||||
|
||||
var supplies1 = _supplyStorage.GetFullList();
|
||||
var recs = _receivingStorage.GetFullList();
|
||||
|
||||
foreach (int id in ids)
|
||||
{
|
||||
var component = _componentStorage.GetElement(new ComponentSearchModel()
|
||||
@ -51,13 +55,12 @@ namespace ComputerShopBusinessLogic.BusinessLogics
|
||||
|
||||
var receivings = new List<EquipmentReceivingViewModel>();
|
||||
|
||||
|
||||
foreach(var supply in supplies)
|
||||
{
|
||||
if (supply.ReceivingId.HasValue)
|
||||
{
|
||||
var receiving = _receivingStorage.GetElement(new() { Id = supply.ReceivingId.Value });
|
||||
if (receiving != null && receivings.Contains(receiving))
|
||||
if (receiving != null && !receivings.Contains(receiving))
|
||||
{
|
||||
receivings.Add(receiving);
|
||||
}
|
||||
@ -68,7 +71,7 @@ namespace ComputerShopBusinessLogic.BusinessLogics
|
||||
var receivingnames = new List<string>();
|
||||
foreach (var receiving in receivings)
|
||||
{
|
||||
receivingnames.Add($"Id: {receiving.Id}. Date: {receiving.Status}.");
|
||||
receivingnames.Add($"Id: {receiving.Id}. Status: {Enum.GetName(typeof(EquipmentReceivingStatus), receiving.Status)}.");
|
||||
}
|
||||
if(receivingnames.Count > 0 && component != null)
|
||||
{
|
||||
|
@ -18,12 +18,18 @@ namespace ComputerShopContracts.BindingModels
|
||||
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
|
||||
public DateTime? DateImplement { get; set; }
|
||||
|
||||
public DateTime? DateImplement { get; set; }
|
||||
|
||||
public Dictionary<int, IOrderModel> SupplyOrders
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = new();
|
||||
|
||||
public Dictionary<int, IComponentModel> SupplyComponents
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = new();
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,11 @@ namespace ComputerShopContracts.ViewModels
|
||||
get;
|
||||
set;
|
||||
} = new();
|
||||
public Dictionary<int, IComponentModel> SupplyComponents
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = new();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ namespace ComputerShopDatabaseImplement
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-IRUVF5S\SQLEXPRESS;Initial Catalog=ComputerShopDatabaseCW;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-IRUVF5S\SQLEXPRESS;Initial Catalog=ComputerShopDatabaseCWW;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ namespace ComputerShopDatabaseImplement.Implements
|
||||
return new();
|
||||
}
|
||||
using var context = new ComputerShopDatabase();
|
||||
if(model.ComponentId.HasValue)
|
||||
if(!model.ComponentId.HasValue)
|
||||
return context.Supplies
|
||||
.Include(x => x.Orders)
|
||||
.ThenInclude(x => x.Order)
|
||||
@ -66,9 +66,9 @@ namespace ComputerShopDatabaseImplement.Implements
|
||||
.Include(x => x.Orders)
|
||||
.ThenInclude(x => x.Order)
|
||||
.Include(x => x.Receiving)
|
||||
.Include(x => x.ComponentSupplies)
|
||||
.Include(x => x.Components)
|
||||
.ThenInclude(x => x.Component)
|
||||
.Where(x => x.ComponentSupplies.Any(x => x.ComponentId == model.ComponentId))
|
||||
.Where(x => x.Components.Any(x => x.ComponentId == model.ComponentId))
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
@ -80,6 +80,8 @@ namespace ComputerShopDatabaseImplement.Implements
|
||||
return context.Supplies
|
||||
.Include(x => x.Orders)
|
||||
.ThenInclude(x => x.Order)
|
||||
.Include(x => x.Components)
|
||||
.ThenInclude(x => x.Component)
|
||||
.Include(x => x.Receiving)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
|
538
ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20230524135850_ordermig.Designer.cs
generated
Normal file
538
ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20230524135850_ordermig.Designer.cs
generated
Normal file
@ -0,0 +1,538 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using ComputerShopDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ComputerShopDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(ComputerShopDatabase))]
|
||||
[Migration("20230524135850_ordermig")]
|
||||
partial class ordermig
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Assembly", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("AssemblyName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.ToTable("Assemblies");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AssemblyId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AssemblyId");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.ToTable("AssemblyComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyOrder", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AssemblyId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("OrderId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AssemblyId");
|
||||
|
||||
b.HasIndex("OrderId");
|
||||
|
||||
b.ToTable("AssemblyOrders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ClientFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ComponentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ComponentSupply", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("SupplyId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.HasIndex("SupplyId");
|
||||
|
||||
b.ToTable("ComponentSupplies");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.EquipmentReceiving", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.ToTable("EquipmentReceivings");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ComponentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.ToTable("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int?>("ReceivingId")
|
||||
.IsRequired()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("ReceivingId");
|
||||
|
||||
b.ToTable("Supplies");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.SupplyOrder", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("OrderId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("SupplyId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OrderId");
|
||||
|
||||
b.HasIndex("SupplyId");
|
||||
|
||||
b.ToTable("SupplyOrders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Assembly", b =>
|
||||
{
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany("Assemblies")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Client");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyComponent", b =>
|
||||
{
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Assembly", "Assembly")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("AssemblyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("AssemblyComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Assembly");
|
||||
|
||||
b.Navigation("Component");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyOrder", b =>
|
||||
{
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Assembly", "Assembly")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("AssemblyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Order", "Order")
|
||||
.WithMany("Assemblies")
|
||||
.HasForeignKey("OrderId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Assembly");
|
||||
|
||||
b.Navigation("Order");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ComponentSupply", b =>
|
||||
{
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("Supplies")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Supply", "Supply")
|
||||
.WithMany("ComponentSupplies")
|
||||
.HasForeignKey("SupplyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Supply");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.EquipmentReceiving", b =>
|
||||
{
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
|
||||
.WithMany("EquipmentReceivings")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany("Purchases")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("Purchases")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Component");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b =>
|
||||
{
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
|
||||
.WithMany("Supplies")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.EquipmentReceiving", "Receiving")
|
||||
.WithMany("Supplies")
|
||||
.HasForeignKey("ReceivingId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Receiving");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.SupplyOrder", b =>
|
||||
{
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Order", "Order")
|
||||
.WithMany("SupplyOrders")
|
||||
.HasForeignKey("OrderId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Supply", "Supply")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("SupplyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Order");
|
||||
|
||||
b.Navigation("Supply");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Assembly", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Navigation("Assemblies");
|
||||
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("EquipmentReceivings");
|
||||
|
||||
b.Navigation("Orders");
|
||||
|
||||
b.Navigation("Purchases");
|
||||
|
||||
b.Navigation("Supplies");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("AssemblyComponents");
|
||||
|
||||
b.Navigation("Purchases");
|
||||
|
||||
b.Navigation("Supplies");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.EquipmentReceiving", b =>
|
||||
{
|
||||
b.Navigation("Supplies");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Navigation("Assemblies");
|
||||
|
||||
b.Navigation("SupplyOrders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b =>
|
||||
{
|
||||
b.Navigation("ComponentSupplies");
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ComputerShopDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class ordermig : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "OrderId",
|
||||
table: "Supplies");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "OrderId",
|
||||
table: "Supplies",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
}
|
||||
}
|
||||
}
|
@ -288,10 +288,8 @@ namespace ComputerShopDatabaseImplement.Migrations
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("OrderId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ReceivingId")
|
||||
b.Property<int?>("ReceivingId")
|
||||
.IsRequired()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
|
@ -22,8 +22,6 @@ namespace ComputerShopDatabaseImplement.Models
|
||||
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
||||
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
|
||||
public int OrderId { get; set; }
|
||||
public int ClientId { get; set; }
|
||||
|
||||
public int? ReceivingId { get; set; }
|
||||
@ -31,6 +29,7 @@ namespace ComputerShopDatabaseImplement.Models
|
||||
|
||||
private Dictionary<int, IOrderModel>? _supplyOrders =
|
||||
null;
|
||||
private Dictionary<int, IComponentModel>? _supplyComponents = null;
|
||||
[NotMapped]
|
||||
public Dictionary<int, IOrderModel> SupplyOrders
|
||||
{
|
||||
@ -44,10 +43,23 @@ namespace ComputerShopDatabaseImplement.Models
|
||||
return _supplyOrders;
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public Dictionary<int, IComponentModel> SupplyComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_supplyComponents == null)
|
||||
{
|
||||
_supplyComponents = Components
|
||||
.ToDictionary(recPC => recPC.SupplyId, recPC => recPC.Component as IComponentModel);
|
||||
}
|
||||
return _supplyComponents;
|
||||
}
|
||||
}
|
||||
[ForeignKey("SupplyId")]
|
||||
public virtual List<SupplyOrder> Orders { get; set; } = new();
|
||||
[ForeignKey("SupplyId")]
|
||||
public virtual List<ComponentSupply> ComponentSupplies { get; set; } = new();
|
||||
public virtual List<ComponentSupply> Components { get; set; } = new();
|
||||
|
||||
public static Supply Create(ComputerShopDatabase context, SupplyBindingModel model)
|
||||
{
|
||||
@ -58,10 +70,16 @@ namespace ComputerShopDatabaseImplement.Models
|
||||
Status = model.Status,
|
||||
DateCreate = model.DateCreate,
|
||||
DateImplement = model.DateImplement,
|
||||
ReceivingId = model.ReceivingId,
|
||||
Orders = model.SupplyOrders.Select(x => new
|
||||
SupplyOrder
|
||||
{
|
||||
Order = context.Orders.First(y => y.Id == x.Key),
|
||||
}).ToList(),
|
||||
Components = model.SupplyComponents.Select(x => new
|
||||
ComponentSupply
|
||||
{
|
||||
Component = context.Components.First(y => y.Id == x.Key),
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
@ -81,6 +99,8 @@ namespace ComputerShopDatabaseImplement.Models
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement,
|
||||
SupplyOrders = SupplyOrders,
|
||||
SupplyComponents = SupplyComponents,
|
||||
ReceivingId = ReceivingId,
|
||||
ClientId = ClientId
|
||||
};
|
||||
public void UpdateOrders(ComputerShopDatabase context, SupplyBindingModel model)
|
||||
|
Loading…
Reference in New Issue
Block a user