Compare commits
No commits in common. "d7ab3a10c4fd169a6e79833c370412425467c8f5" and "46477a6c6fe4650209d9ab4790ccca1ab62b404c" have entirely different histories.
d7ab3a10c4
...
46477a6c6f
@ -52,7 +52,7 @@ namespace ComputerShopBusinessLogic.BusinessLogics
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TakeInWork(EquipmentReceivingBindingModel model)
|
public bool TakeOrderInWork(EquipmentReceivingBindingModel model)
|
||||||
{
|
{
|
||||||
return StatusUpdate(model, EquipmentReceivingStatus.Ожидается);
|
return StatusUpdate(model, EquipmentReceivingStatus.Ожидается);
|
||||||
}
|
}
|
||||||
@ -92,5 +92,10 @@ namespace ComputerShopBusinessLogic.BusinessLogics
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool TakeInWork(EquipmentReceivingBindingModel model)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,13 +18,11 @@ namespace ComputerShopBusinessLogic.BusinessLogics
|
|||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IOrderStorage _orderStorage;
|
private readonly IOrderStorage _orderStorage;
|
||||||
private readonly IAssemblyStorage _assemblyStorage;
|
private readonly IAssemblyStorage _assemblyStorage;
|
||||||
private readonly ISupplyStorage _supplyStorage;
|
public OrderLogic(ILogger<ComponentLogic> logger, IOrderStorage orderStorage, IAssemblyStorage assemblyStorage)
|
||||||
public OrderLogic(ILogger<ComponentLogic> logger, IOrderStorage orderStorage, IAssemblyStorage assemblyStorage, ISupplyStorage supplyStorage)
|
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_orderStorage = orderStorage;
|
_orderStorage = orderStorage;
|
||||||
_assemblyStorage = assemblyStorage;
|
_assemblyStorage = assemblyStorage;
|
||||||
_supplyStorage = supplyStorage;
|
|
||||||
}
|
}
|
||||||
public bool CreateOrder(OrderBindingModel model)
|
public bool CreateOrder(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
@ -164,6 +162,5 @@ namespace ComputerShopBusinessLogic.BusinessLogics
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,13 +17,10 @@ namespace ComputerShopBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly ISupplyStorage _supplyStorage;
|
private readonly ISupplyStorage _supplyStorage;
|
||||||
private readonly IOrderStorage _orderStorage;
|
public SupplyLogic(ILogger logger, ISupplyStorage supplyStorage)
|
||||||
|
|
||||||
public SupplyLogic(ILogger logger, ISupplyStorage supplyStorage, IOrderStorage orderStorage)
|
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_supplyStorage = supplyStorage;
|
_supplyStorage = supplyStorage;
|
||||||
_orderStorage = orderStorage;
|
|
||||||
}
|
}
|
||||||
public bool Create(SupplyBindingModel model)
|
public bool Create(SupplyBindingModel model)
|
||||||
{
|
{
|
||||||
@ -115,31 +112,5 @@ namespace ComputerShopBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool AddOrder(SupplySearchModel supplymodel, OrderSearchModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
|
|
||||||
var order = _orderStorage.GetElement(model);
|
|
||||||
var supply = _supplyStorage.GetElement(supplymodel);
|
|
||||||
|
|
||||||
if (order == null || supply == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
order.SupplyOrders[order.Id] = order;
|
|
||||||
|
|
||||||
_supplyStorage.Update(new()
|
|
||||||
{
|
|
||||||
Id = supply.Id,
|
|
||||||
SupplyOrders = supply.SupplyOrders,
|
|
||||||
});
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ namespace ComputerShopContracts.BindingModels
|
|||||||
public class EquipmentReceivingBindingModel : IEquipmentReceivingModel
|
public class EquipmentReceivingBindingModel : IEquipmentReceivingModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public int ClientId { get; set; }
|
|
||||||
public EquipmentReceivingStatus Status { get; set; } = EquipmentReceivingStatus.Неизвестен;
|
public EquipmentReceivingStatus Status { get; set; } = EquipmentReceivingStatus.Неизвестен;
|
||||||
|
|
||||||
public DateTime? DateImplement { get; set; }
|
public DateTime? DateImplement { get; set; }
|
||||||
|
@ -11,9 +11,7 @@ namespace ComputerShopContracts.BindingModels
|
|||||||
public class SupplyBindingModel : ISupplyModel
|
public class SupplyBindingModel : ISupplyModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public int ClientId { get; set; }
|
public int? ReceivingId { get; set; }
|
||||||
|
|
||||||
public int ReceivingId { get; set; }
|
|
||||||
public SupplyStatus Status { get; set; } = SupplyStatus.Неизвестен;
|
public SupplyStatus Status { get; set; } = SupplyStatus.Неизвестен;
|
||||||
|
|
||||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||||
|
@ -18,6 +18,5 @@ namespace ComputerShopContracts.BusinessLogicContracts
|
|||||||
bool Delete(SupplyBindingModel model);
|
bool Delete(SupplyBindingModel model);
|
||||||
bool TakeInWork(SupplyBindingModel model);
|
bool TakeInWork(SupplyBindingModel model);
|
||||||
bool Finish(SupplyBindingModel model);
|
bool Finish(SupplyBindingModel model);
|
||||||
bool AddOrder(SupplySearchModel supplymodel, OrderSearchModel model);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ namespace ComputerShopContracts.SearchModels
|
|||||||
public class EquipmentReceivingSearchModel
|
public class EquipmentReceivingSearchModel
|
||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
public int? ClientId { get; set; }
|
|
||||||
public DateTime? DateFrom { get; set; }
|
public DateTime? DateFrom { get; set; }
|
||||||
public DateTime? DateTo { get; set; }
|
public DateTime? DateTo { get; set; }
|
||||||
public SupplySearchModel? Supply { get; set; }
|
public SupplySearchModel? Supply { get; set; }
|
||||||
|
@ -9,7 +9,6 @@ namespace ComputerShopContracts.SearchModels
|
|||||||
public class SupplySearchModel
|
public class SupplySearchModel
|
||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
public int? ClientId { get; set; }
|
|
||||||
public DateTime? DateFrom { get; set; }
|
public DateTime? DateFrom { get; set; }
|
||||||
public DateTime? DateTo { get; set; }
|
public DateTime? DateTo { get; set; }
|
||||||
public ComponentSearchModel? Component { get; set; }
|
public ComponentSearchModel? Component { get; set; }
|
||||||
|
@ -19,7 +19,5 @@ namespace ComputerShopContracts.ViewModels
|
|||||||
|
|
||||||
[DisplayName("Номер")]
|
[DisplayName("Номер")]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("Номер клиента")]
|
|
||||||
public int ClientId { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ namespace ComputerShopContracts.ViewModels
|
|||||||
get;
|
get;
|
||||||
set;
|
set;
|
||||||
} = new();
|
} = new();
|
||||||
public Dictionary<int, IOrderModel> SupplyOrders
|
public Dictionary<int, ISupplyModel> SupplyOrders
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
set;
|
set;
|
||||||
|
@ -22,9 +22,6 @@ namespace ComputerShopContracts.ViewModels
|
|||||||
|
|
||||||
[DisplayName("Номер")]
|
[DisplayName("Номер")]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
[DisplayName("Номер клиента")]
|
|
||||||
public int ClientId { get; set; }
|
|
||||||
[DisplayName("Номер получения")]
|
[DisplayName("Номер получения")]
|
||||||
public int? ReceivingId { get; set; }
|
public int? ReceivingId { get; set; }
|
||||||
public Dictionary<int, IOrderModel> SupplyOrders
|
public Dictionary<int, IOrderModel> SupplyOrders
|
||||||
|
@ -1,540 +0,0 @@
|
|||||||
// <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("20230520051723_fix")]
|
|
||||||
partial class fix
|
|
||||||
{
|
|
||||||
/// <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>("OrderId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("ReceivingId")
|
|
||||||
.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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,141 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace ComputerShopDatabaseImplement.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class fix : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropForeignKey(
|
|
||||||
name: "FK_EquipmentReceivings_Clients_ClientId",
|
|
||||||
table: "EquipmentReceivings");
|
|
||||||
|
|
||||||
migrationBuilder.DropForeignKey(
|
|
||||||
name: "FK_Orders_Clients_ClientId",
|
|
||||||
table: "Orders");
|
|
||||||
|
|
||||||
migrationBuilder.DropForeignKey(
|
|
||||||
name: "FK_Supplies_Clients_ClientId",
|
|
||||||
table: "Supplies");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "ClientId",
|
|
||||||
table: "Supplies",
|
|
||||||
type: "int",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "int",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "ClientId",
|
|
||||||
table: "Orders",
|
|
||||||
type: "int",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "int",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "ClientId",
|
|
||||||
table: "EquipmentReceivings",
|
|
||||||
type: "int",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "int",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AddForeignKey(
|
|
||||||
name: "FK_EquipmentReceivings_Clients_ClientId",
|
|
||||||
table: "EquipmentReceivings",
|
|
||||||
column: "ClientId",
|
|
||||||
principalTable: "Clients",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.NoAction);
|
|
||||||
|
|
||||||
migrationBuilder.AddForeignKey(
|
|
||||||
name: "FK_Orders_Clients_ClientId",
|
|
||||||
table: "Orders",
|
|
||||||
column: "ClientId",
|
|
||||||
principalTable: "Clients",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.NoAction);
|
|
||||||
|
|
||||||
migrationBuilder.AddForeignKey(
|
|
||||||
name: "FK_Supplies_Clients_ClientId",
|
|
||||||
table: "Supplies",
|
|
||||||
column: "ClientId",
|
|
||||||
principalTable: "Clients",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.NoAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropForeignKey(
|
|
||||||
name: "FK_EquipmentReceivings_Clients_ClientId",
|
|
||||||
table: "EquipmentReceivings");
|
|
||||||
|
|
||||||
migrationBuilder.DropForeignKey(
|
|
||||||
name: "FK_Orders_Clients_ClientId",
|
|
||||||
table: "Orders");
|
|
||||||
|
|
||||||
migrationBuilder.DropForeignKey(
|
|
||||||
name: "FK_Supplies_Clients_ClientId",
|
|
||||||
table: "Supplies");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "ClientId",
|
|
||||||
table: "Supplies",
|
|
||||||
type: "int",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "int");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "ClientId",
|
|
||||||
table: "Orders",
|
|
||||||
type: "int",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "int");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "ClientId",
|
|
||||||
table: "EquipmentReceivings",
|
|
||||||
type: "int",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "int");
|
|
||||||
|
|
||||||
migrationBuilder.AddForeignKey(
|
|
||||||
name: "FK_EquipmentReceivings_Clients_ClientId",
|
|
||||||
table: "EquipmentReceivings",
|
|
||||||
column: "ClientId",
|
|
||||||
principalTable: "Clients",
|
|
||||||
principalColumn: "Id");
|
|
||||||
|
|
||||||
migrationBuilder.AddForeignKey(
|
|
||||||
name: "FK_Orders_Clients_ClientId",
|
|
||||||
table: "Orders",
|
|
||||||
column: "ClientId",
|
|
||||||
principalTable: "Clients",
|
|
||||||
principalColumn: "Id");
|
|
||||||
|
|
||||||
migrationBuilder.AddForeignKey(
|
|
||||||
name: "FK_Supplies_Clients_ClientId",
|
|
||||||
table: "Supplies",
|
|
||||||
column: "ClientId",
|
|
||||||
principalTable: "Clients",
|
|
||||||
principalColumn: "Id");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -183,7 +183,7 @@ namespace ComputerShopDatabaseImplement.Migrations
|
|||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<int>("ClientId")
|
b.Property<int?>("ClientId")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<DateTime?>("DateImplement")
|
b.Property<DateTime?>("DateImplement")
|
||||||
@ -207,7 +207,7 @@ namespace ComputerShopDatabaseImplement.Migrations
|
|||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<int>("ClientId")
|
b.Property<int?>("ClientId")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<DateTime>("DateCreate")
|
b.Property<DateTime>("DateCreate")
|
||||||
@ -279,7 +279,7 @@ namespace ComputerShopDatabaseImplement.Migrations
|
|||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<int>("ClientId")
|
b.Property<int?>("ClientId")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<DateTime>("DateCreate")
|
b.Property<DateTime>("DateCreate")
|
||||||
@ -413,18 +413,14 @@ namespace ComputerShopDatabaseImplement.Migrations
|
|||||||
{
|
{
|
||||||
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
|
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
|
||||||
.WithMany("EquipmentReceivings")
|
.WithMany("EquipmentReceivings")
|
||||||
.HasForeignKey("ClientId")
|
.HasForeignKey("ClientId");
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
|
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
|
||||||
.WithMany("Orders")
|
.WithMany("Orders")
|
||||||
.HasForeignKey("ClientId")
|
.HasForeignKey("ClientId");
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b =>
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b =>
|
||||||
@ -450,17 +446,13 @@ namespace ComputerShopDatabaseImplement.Migrations
|
|||||||
{
|
{
|
||||||
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
|
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
|
||||||
.WithMany("Supplies")
|
.WithMany("Supplies")
|
||||||
.HasForeignKey("ClientId")
|
.HasForeignKey("ClientId");
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("ComputerShopDatabaseImplement.Models.EquipmentReceiving", "Receiving")
|
b.HasOne("ComputerShopDatabaseImplement.Models.EquipmentReceiving", null)
|
||||||
.WithMany("Supplies")
|
.WithMany("Supplies")
|
||||||
.HasForeignKey("ReceivingId")
|
.HasForeignKey("ReceivingId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.Navigation("Receiving");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.SupplyOrder", b =>
|
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.SupplyOrder", b =>
|
||||||
|
@ -38,6 +38,20 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Dictionary<int, (IOrderModel, int)>? _assemblyOrders = null;
|
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")]
|
[ForeignKey("AssemblyId")]
|
||||||
public virtual List<AssemblyComponent> Components { get; set; } = new();
|
public virtual List<AssemblyComponent> Components { get; set; } = new();
|
||||||
[ForeignKey("AssemblyId")]
|
[ForeignKey("AssemblyId")]
|
||||||
@ -76,6 +90,7 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
AssemblyName = AssemblyName,
|
AssemblyName = AssemblyName,
|
||||||
Price = Price,
|
Price = Price,
|
||||||
AssemblyComponents = AssemblyComponents,
|
AssemblyComponents = AssemblyComponents,
|
||||||
|
AssemblyOrders = AssemblyOrders,
|
||||||
ClientId = ClientId
|
ClientId = ClientId
|
||||||
};
|
};
|
||||||
public void UpdateComponents(ComputerShopDatabase context, AssemblyBindingModel model)
|
public void UpdateComponents(ComputerShopDatabase context, AssemblyBindingModel model)
|
||||||
|
@ -22,8 +22,6 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
|
|
||||||
[ForeignKey("ReceivingId")]
|
[ForeignKey("ReceivingId")]
|
||||||
public List<Supply> Supplies { get; set; } = new();
|
public List<Supply> Supplies { get; set; } = new();
|
||||||
[Required]
|
|
||||||
public int ClientId { get; set; }
|
|
||||||
|
|
||||||
public static EquipmentReceiving? Create(EquipmentReceivingBindingModel? model)
|
public static EquipmentReceiving? Create(EquipmentReceivingBindingModel? model)
|
||||||
{
|
{
|
||||||
@ -36,7 +34,6 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
Status = model.Status,
|
Status = model.Status,
|
||||||
DateImplement = model.DateImplement,
|
DateImplement = model.DateImplement,
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
ClientId = model.ClientId
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +52,6 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
DateImplement = DateImplement,
|
DateImplement = DateImplement,
|
||||||
Id = Id,
|
Id = Id,
|
||||||
Status = Status,
|
Status = Status,
|
||||||
ClientId = ClientId
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,8 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
|
|
||||||
public DateTime? DateImplement { get; private set; }
|
public DateTime? DateImplement { get; private set; }
|
||||||
[ForeignKey("OrderId")]
|
[ForeignKey("OrderId")]
|
||||||
public virtual List<SupplyOrder> SupplyOrders { get; set; } = new();
|
public virtual List<SupplyOrder> Supplies { get; set; } = new();
|
||||||
|
private Dictionary<int, IOrderModel>? _supplyOrders = null;
|
||||||
|
|
||||||
[ForeignKey("OrderId")]
|
[ForeignKey("OrderId")]
|
||||||
public virtual List<AssemblyOrder> Assemblies { get; set; } = new();
|
public virtual List<AssemblyOrder> Assemblies { get; set; } = new();
|
||||||
@ -44,6 +45,20 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
return _assemblyOrders;
|
return _assemblyOrders;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
[NotMapped]
|
||||||
|
public Dictionary<int, IOrderModel> SupplyOrders
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_supplyOrders == null)
|
||||||
|
{
|
||||||
|
_supplyOrders = Supplies
|
||||||
|
.ToDictionary(recPC => recPC.SupplyId, recPC =>
|
||||||
|
(recPC.Order as IOrderModel));
|
||||||
|
}
|
||||||
|
return _supplyOrders;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public int ClientId { get; set; }
|
public int ClientId { get; set; }
|
||||||
|
@ -24,7 +24,6 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
public DateTime? DateImplement { get; private set; }
|
public DateTime? DateImplement { get; private set; }
|
||||||
|
|
||||||
public int OrderId { get; set; }
|
public int OrderId { get; set; }
|
||||||
public int ClientId { get; set; }
|
|
||||||
|
|
||||||
public int? ReceivingId { get; set; }
|
public int? ReceivingId { get; set; }
|
||||||
public virtual EquipmentReceiving Receiving { get; set; }
|
public virtual EquipmentReceiving Receiving { get; set; }
|
||||||
@ -54,7 +53,6 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
return new Supply
|
return new Supply
|
||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
ClientId = model.ClientId,
|
|
||||||
Status = model.Status,
|
Status = model.Status,
|
||||||
DateCreate = model.DateCreate,
|
DateCreate = model.DateCreate,
|
||||||
DateImplement = model.DateImplement,
|
DateImplement = model.DateImplement,
|
||||||
@ -80,8 +78,7 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
Status = Status,
|
Status = Status,
|
||||||
DateCreate = DateCreate,
|
DateCreate = DateCreate,
|
||||||
DateImplement = DateImplement,
|
DateImplement = DateImplement,
|
||||||
SupplyOrders = SupplyOrders,
|
SupplyOrders = SupplyOrders
|
||||||
ClientId = ClientId
|
|
||||||
};
|
};
|
||||||
public void UpdateOrders(ComputerShopDatabase context, SupplyBindingModel model)
|
public void UpdateOrders(ComputerShopDatabase context, SupplyBindingModel model)
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
using ComputerShopContracts.BindingModels;
|
using Microsoft.AspNetCore.Http;
|
||||||
using ComputerShopContracts.BusinessLogicContracts;
|
|
||||||
using ComputerShopContracts.SearchModels;
|
|
||||||
using ComputerShopContracts.ViewModels;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace ComputerShopRestApi.Controllers
|
namespace ComputerShopRestApi.Controllers
|
||||||
@ -11,55 +7,6 @@ namespace ComputerShopRestApi.Controllers
|
|||||||
[ApiController]
|
[ApiController]
|
||||||
public class EquipmentReceivingController : Controller
|
public class EquipmentReceivingController : Controller
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IEquipmentReceivingLogic _equipmentReceiving;
|
|
||||||
public EquipmentReceivingController(ILogger<MainController> logger, IEquipmentReceivingLogic equipmentReceiving)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_equipmentReceiving = equipmentReceiving;
|
|
||||||
}
|
|
||||||
[HttpGet]
|
|
||||||
public List<EquipmentReceivingViewModel>? GetReceivingList()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return _equipmentReceiving.ReadList(null);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка получения списка компонентов");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
public List<EquipmentReceivingViewModel>? GetReceivings(int clientId)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return _equipmentReceiving.ReadList(new EquipmentReceivingSearchModel
|
|
||||||
{
|
|
||||||
ClientId = clientId
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка получения списка получений клиента id ={ Id}", clientId);
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[HttpPost]
|
|
||||||
public void CreateReceiving(EquipmentReceivingBindingModel model)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_equipmentReceiving.Create(model);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка создания получения");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,42 +14,26 @@ namespace ComputerShopRestApi.Controllers
|
|||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly ISupplyLogic _supply;
|
private readonly ISupplyLogic _supply;
|
||||||
private readonly IOrderLogic _order;
|
private readonly IOrderLogic _order;
|
||||||
private readonly IEquipmentReceivingLogic _equipmentReceiving;
|
public SupplyController(ILogger<SupplyController> logger, ISupplyLogic supply, IOrderLogic order)
|
||||||
|
|
||||||
public SupplyController(ILogger<SupplyController> logger, ISupplyLogic supply, IOrderLogic order, IEquipmentReceivingLogic equipmentReceiving)
|
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_supply = supply;
|
_supply = supply;
|
||||||
_order = order;
|
_order = order;
|
||||||
_equipmentReceiving = equipmentReceiving;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
/*
|
||||||
public List<EquipmentReceivingViewModel>? GetReceivingList(int clientId)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public List<AssemblyViewModel>? GetAssemblyList(int clientId)
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return _equipmentReceiving.ReadList(new EquipmentReceivingSearchModel
|
return _supply.ReadList(new SupplySearchModel
|
||||||
{
|
{
|
||||||
ClientId = clientId
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка получения списка поставок клиента id ={ Id}", clientId);
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
public List<SupplyViewModel>? GetSupplyList(int componentid)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return _supply.ReadList(new SupplySearchModel { ComponentId = componentid });
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка получения списка сборок");
|
_logger.LogError(ex, "Ошибка получения списка сборок");
|
||||||
throw;
|
throw;
|
||||||
@ -57,72 +41,91 @@ namespace ComputerShopRestApi.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public List<OrderViewModel>? GetOrderList()
|
public Tuple<AssemblyViewModel, List<Tuple<string, int>>>? GetAssembly(int assemblyId)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return _order.ReadList(null);
|
var elem = _supply.ReadElement(new SupplySearchModel { Id = assemblyId });
|
||||||
|
if (elem == null)
|
||||||
|
return null;
|
||||||
|
return Tuple.Create(elem, elem.AssemblyComponents.Select(x => Tuple.Create(x.Value.Item1.ComponentName, x.Value.Item2)).ToList());
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка получения списка заказов");
|
_logger.LogError(ex, "Ошибка получения сборки по id={Id}", assemblyId);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public List<ComponentViewModel>? GetComponentList()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _component.ReadList(null);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка получения списка компонентов");
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void CreateSupply(SupplyBindingModel model)
|
public void CreateAssembly(AssemblyBindingModel model)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_supply.Create(model);
|
_assembly.Create(model);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка создания поставки");
|
_logger.LogError(ex, "Ошибка создания сборки");
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void DeleteSupply(SupplyBindingModel model)
|
public void DeleteAssembly(AssemblyBindingModel model)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_supply.Delete(model);
|
_assembly.Delete(model);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка удаления поставки");
|
_logger.LogError(ex, "Ошибка удаления сборки");
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void AddOrderToSupply(Tuple<SupplySearchModel, OrderSearchModel> model)
|
public void AddComponentToAssembly(Tuple<AssemblySearchModel, ComponentSearchModel, int> model)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_supply.AddOrder(model.Item1, model.Item2);
|
_assembly.AddComponentToAssembly(model.Item1, model.Item2, model.Item3);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка.");
|
_logger.LogError(ex, "Ошибка добавления компонента в сборку.");
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void EditOrder(OrderBindingModel model)
|
public void EditAssembly(AssemblyBindingModel model)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_order.Update(model);
|
_assembly.Update(model);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка удаления заказа");
|
_logger.LogError(ex, "Ошибка удаления сборки");
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,43 +127,54 @@ namespace OrdererClientApp.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult CreateEquipmentReceiving()
|
public IActionResult CreatePurchase()
|
||||||
{
|
{
|
||||||
ViewBag.EquipmentReceivings = APIClient.GetRequest<List<EquipmentReceivingViewModel>>("api/main/getreceivingslist");
|
ViewBag.Components = APIClient.GetRequest<List<ComponentViewModel>>("api/main/getcomponentlist");
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void CreateSupply(int receiving)
|
public void CreatePurchase(int component, int count)
|
||||||
{
|
{
|
||||||
if (APIClient.Client == null)
|
if (APIClient.Client == null)
|
||||||
{
|
{
|
||||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||||
}
|
}
|
||||||
|
if (count <= 0)
|
||||||
APIClient.PostRequest("api/main/createreceiving", new SupplyBindingModel
|
{
|
||||||
|
throw new Exception("Количество и сумма должны быть больше 0");
|
||||||
|
}
|
||||||
|
APIClient.PostRequest("api/main/createpurchase", new PurchaseBindingModel
|
||||||
{
|
{
|
||||||
ClientId = APIClient.Client.Id,
|
ClientId = APIClient.Client.Id,
|
||||||
ReceivingId = receiving,
|
ComponentId = component,
|
||||||
|
Count = count,
|
||||||
|
Sum = Calc(count, component)
|
||||||
});
|
});
|
||||||
Response.Redirect("Index");
|
Response.Redirect("Index");
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult CreateOrder()
|
public IActionResult CreateComponent()
|
||||||
{
|
{
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void CreateOrder(int sum)
|
public void CreateComponent(string name, int cost)
|
||||||
{
|
{
|
||||||
if (APIClient.Client == null)
|
if (APIClient.Client == null)
|
||||||
{
|
{
|
||||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||||
}
|
}
|
||||||
APIClient.PostRequest("api/order/createorder", new OrderBindingModel
|
if (cost <= 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Цена должна быть больше 0");
|
||||||
|
}
|
||||||
|
APIClient.PostRequest("api/component/createcomponent", new ComponentBindingModel
|
||||||
{
|
{
|
||||||
ClientId = APIClient.Client.Id,
|
ClientId = APIClient.Client.Id,
|
||||||
|
ComponentName = name,
|
||||||
|
Cost = cost
|
||||||
});
|
});
|
||||||
Response.Redirect("Index");
|
Response.Redirect("Index");
|
||||||
}
|
}
|
||||||
@ -207,13 +218,13 @@ namespace OrdererClientApp.Controllers
|
|||||||
{
|
{
|
||||||
throw new Exception("Сумма должна быть больше 0");
|
throw new Exception("Сумма должна быть больше 0");
|
||||||
}
|
}
|
||||||
APIClient.PostRequest("api/assembly/createassembly", new AssemblyBindingModel
|
//APIClient.PostRequest("api/assembly/createassembly", new AssemblyBindingModel
|
||||||
{
|
//{
|
||||||
ClientId = APIClient.Client.Id,
|
// ClientId = APIClient.Client.Id,
|
||||||
AssemblyName = name,
|
// AssemblyName = name,
|
||||||
Price = 0,
|
// Price = 0,
|
||||||
AssemblyComponents = new()
|
// AssemblyComponents = new()
|
||||||
});
|
//});
|
||||||
System.Diagnostics.Debug.WriteLine("it might work");
|
System.Diagnostics.Debug.WriteLine("it might work");
|
||||||
Response.Redirect("Index");
|
Response.Redirect("Index");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user