гиперфиксация

This commit is contained in:
devil_1nc 2024-07-26 02:49:24 +04:00
parent 96037fbe66
commit 0cb59e78e9
36 changed files with 2816 additions and 223 deletions

View File

@ -17,12 +17,12 @@ namespace ComputerShopBusinessLogic.BusinessLogics
{
private readonly ILogger _logger;
private readonly IOrderStorage _orderStorage;
private readonly IAssemblyStorage _assemblyStorage;
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IAssemblyStorage assemblyStorage)
private readonly IComponentStorage _componentStorage;
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IComponentStorage componentStorage)
{
_logger = logger;
_orderStorage = orderStorage;
_assemblyStorage = assemblyStorage;
_componentStorage = componentStorage;
}
public bool CreateOrder(OrderBindingModel model)
{
@ -99,22 +99,17 @@ namespace ComputerShopBusinessLogic.BusinessLogics
_logger.LogWarning("Order model not found");
return false;
}
OrderBindingModel model = new OrderBindingModel
{
Id = viewModel.Id,
ClientId = viewModel.ClientId,
Status = viewModel.Status,
DateCreate = viewModel.DateCreate,
DateImplement = viewModel.DateImplement,
Sum = viewModel.Sum
};
CheckModel(rawModel, false);
if (rawModel.Status + 1 != _newStatus)
{
_logger.LogWarning("Status update to " + _newStatus.ToString() + " operation failed. Order status incorrect.");
return false;
}
if (rawModel.Status == OrderStatus.Выдан) rawModel.DateImplement = DateTime.Now;
rawModel.Status = _newStatus;
if (rawModel.Status == OrderStatus.Выдан)
rawModel.DateImplement = DateTime.Now;
if (_orderStorage.Update(rawModel) == null)
{
rawModel.Status--;
@ -139,39 +134,39 @@ namespace ComputerShopBusinessLogic.BusinessLogics
}
if (model.Sum <= 0)
{
throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum));
}
_logger.LogInformation("Order. OrderID:{Id}. Sum:{ Sum}. ClientId: { ClientId}", model.Id, model.Sum, model.ClientId);
}
public bool AddAssembly(OrderSearchModel model, AssemblySearchModel assemblymodel, int amount)
public bool AddComponent(OrderSearchModel model, ComponentSearchModel componentmodel, int amount)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("AddAssemblyToOrder. AssemblyName:{AssemblyName}.Id:{ Id}", assemblymodel.AssemblyName, model.Id);
_logger.LogInformation("AddComponentToOrder. AssemblyName:{AssemblyName}.Id:{ Id}", componentmodel.ComponentName, model.Id);
var order = _orderStorage.GetElement(model);
var assembly = _assemblyStorage.GetElement(assemblymodel);
var component = _componentStorage.GetElement(componentmodel);
if (order == null || assembly == null)
if (order == null || component == null)
{
return false;
}
_logger.LogInformation("AddAssemblyToOrder find. Id:{Id}", order.Id);
_logger.LogInformation("AddComponentToOrder find. Id:{Id}", order.Id);
order.OrderAssemblies[assembly.Id] = (assembly, amount);
order.OrderComponents[component.Id] = (component, amount);
_orderStorage.Update(new()
{
Id = order.Id,
Status = order.Status,
Sum = order.Sum + assembly.Price * amount,
Sum = order.Sum + component.Cost * amount,
ClientId = order.ClientId,
AssemblyOrders = order.OrderAssemblies
});
OrderComponents = order.OrderComponents
});
return true;
}

View File

@ -18,10 +18,5 @@ namespace ComputerShopContracts.BindingModels
get;
set;
} = new();
public Dictionary<int, (IOrderModel, int)> AssemblyOrders
{
get;
set;
} = new();
}
}

View File

@ -15,12 +15,12 @@ namespace ComputerShopContracts.BindingModels
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
public DateTime DateCreate { get; set; }
public DateTime DateCreate { get; set; } = DateTime.Now;
public DateTime? DateImplement { get; set; } = DateTime.Now;
public DateTime? DateImplement { get; set; }
public int ClientId { get; set; }
public Dictionary<int, (IAssemblyModel, int)> AssemblyOrders
{
public Dictionary<int, (IComponentModel, int)> OrderComponents
{
get;
set;
} = new();

View File

@ -18,6 +18,6 @@ namespace ComputerShopContracts.BusinessLogicContracts
bool TakeOrderInWork(OrderBindingModel model);
bool FinishOrder(OrderBindingModel model);
bool DeliveryOrder(OrderBindingModel model);
bool AddAssembly(OrderSearchModel ordermodel, AssemblySearchModel model, int amount);
bool AddComponent(OrderSearchModel ordermodel, ComponentSearchModel model, int amount);
}
}

View File

@ -11,5 +11,6 @@ namespace ComputerShopContracts.SearchModels
public int? Id { get; set; }
public string? ComponentName { get; set; }
public int? ClientId { get; set; }
public int? OrderId { get; set; }
}
}

View File

@ -17,5 +17,6 @@ namespace ComputerShopContracts.StorageContracts
OrderViewModel? Insert(OrderBindingModel model);
OrderViewModel? Update(OrderBindingModel model);
OrderViewModel? Delete(OrderBindingModel model);
}
ComponentViewModel? GetComponentsByOrder(OrderSearchModel model);
}
}

View File

@ -19,8 +19,8 @@ namespace ComputerShopContracts.ViewModels
[DisplayName("Дата создания")]
public DateTime DateCreate { get; set; } = DateTime.Now;
public Dictionary<int, (IAssemblyModel, int)> OrderAssemblies
{
public Dictionary<int, (IComponentModel, int)> OrderComponents
{
get;
set;
} = new();

View File

@ -8,5 +8,6 @@ namespace ComputerShopDataModels.Models
OrderStatus Status { get; }
DateTime DateCreate { get; }
DateTime? DateImplement { get; }
}
Dictionary<int, (IComponentModel, int)> OrderComponents { get; }
}
}

View File

@ -8,7 +8,6 @@ namespace ComputerShopDataModels.Models
DateTime DateCreate { get; }
DateTime? DateImplement { get; }
int? ReceivingId { get; }
int? ComponentId { get; }
Dictionary<int, IOrderModel> SupplyOrders { get; }
}
}

View File

@ -28,7 +28,7 @@ namespace ComputerShopDatabaseImplement
public virtual DbSet<SupplyOrder> SupplyOrders { set; get; }
public virtual DbSet<EquipmentReceiving> EquipmentReceivings { set; get; }
public virtual DbSet<ComponentSupply> ComponentSupplies { set; get; }
public virtual DbSet<OrderAssembly> AssemblyOrders { set; get; }
public virtual DbSet<OrderComponent> OrderComponents { set; get; }
public virtual DbSet<Client> Clients { set; get; }
}
}
}

View File

@ -34,8 +34,7 @@ namespace ComputerShopDatabaseImplement.Implements
return null;
}
using var context = new ComputerShopDatabase();
return context.EquipmentReceivings
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
return context.EquipmentReceivings.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
}
public List<EquipmentReceivingViewModel> GetFilteredList(EquipmentReceivingSearchModel model)

View File

@ -35,54 +35,57 @@ namespace ComputerShopDatabaseImplement.Implements
return null;
}
using var context = new ComputerShopDatabase();
return context.Orders
.FirstOrDefault(x =>
(model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
return context.Orders.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
}
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
using var context = new ComputerShopDatabase();
if (model.ClientId.HasValue)
if (!model.ClientId.HasValue)
{
return context.Orders
.Include(x => x.Assemblies)
.Include(x => x.Client)
return new();
}
using var context = new ComputerShopDatabase();
if (model.DateFrom.HasValue & model.DateTo.HasValue)
{
return context.Orders
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
.Include(x => x.OrderComponents).Include(x => x.Client)
.Select(x => x.GetViewModel)
.ToList();
}
return context.Orders
.Include(x => x.Components)
.ThenInclude(x => x.Component)
.Where(x => x.ClientId == model.ClientId)
.Select(x => x.GetViewModel)
.ToList();
}
return context.Orders
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
.Include(x => x.Assemblies).Include(x => x.Client)
.Select(x => x.GetViewModel)
.ToList();
}
public List<OrderViewModel> GetFullList()
{
using var context = new ComputerShopDatabase();
return context.Orders
.Include(x => x.Assemblies).Include(x => x.Client)
.Include(x => x.OrderComponents).Include(x => x.Client)
.Select(x => x.GetViewModel)
.ToList();
}
public OrderViewModel? Insert(OrderBindingModel model)
{
var newOrder = Order.Create(model);
using var context = new ComputerShopDatabase();
var newOrder = Order.Create(context, model);
if (newOrder == null)
{
return null;
}
using var context = new ComputerShopDatabase();
context.Orders.Add(newOrder);
context.SaveChanges();
return context.Orders.Include(x => x.Assemblies).Include(x => x.Client).FirstOrDefault(x => x.Id == newOrder.Id)?.GetViewModel;
}
return newOrder.GetViewModel;
}
public OrderViewModel? Update(OrderBindingModel model)
{
@ -94,7 +97,23 @@ namespace ComputerShopDatabaseImplement.Implements
}
order.Update(model);
context.SaveChanges();
return context.Orders.Include(x => x.Assemblies).FirstOrDefault(x => x.Id == order.Id)?.GetViewModel;
return order.GetViewModel;
}
public ComponentViewModel? GetComponentsByOrder(OrderSearchModel model)
{
using var context = new ComputerShopDatabase();
var order_components = context.OrderComponents.FirstOrDefault(x => x.OrderId == model.Id);
if (order_components == null)
{
return null;
}
var components = context.Components.FirstOrDefault(x => x.Id == order_components.Id);
if (components == null)
{
return null;
}
return components.GetViewModel;
}
}
}

View File

@ -0,0 +1,550 @@
// <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("20240516194435_1605")]
partial class _1605
{
/// <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.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.OrderAssembly", 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.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<int?>("ComponentId")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2");
b.Property<int?>("ReceivingId")
.HasColumnType("int");
b.Property<int>("Status")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ClientId");
b.HasIndex("ComponentId");
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.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("Components")
.HasForeignKey("SupplyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Component");
b.Navigation("Supply");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.EquipmentReceiving", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", "Client")
.WithMany("EquipmentReceivings")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", "Client")
.WithMany("Orders")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.OrderAssembly", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Assembly", "Assembly")
.WithMany()
.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.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", "Client")
.WithMany("Supplies")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
.WithMany()
.HasForeignKey("ComponentId");
b.HasOne("ComputerShopDatabaseImplement.Models.EquipmentReceiving", "Receiving")
.WithMany("Supplies")
.HasForeignKey("ReceivingId");
b.Navigation("Client");
b.Navigation("Component");
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");
});
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("Components");
b.Navigation("Orders");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ComputerShopDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class _1605 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@ -0,0 +1,548 @@
// <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("20240517100456_component")]
partial class component
{
/// <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.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.OrderComponent", 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>("OrderId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ComponentId");
b.HasIndex("OrderId");
b.ToTable("AssemblyOrders");
});
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("OrderId");
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.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("Components")
.HasForeignKey("SupplyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Component");
b.Navigation("Supply");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.EquipmentReceiving", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", "Client")
.WithMany("EquipmentReceivings")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", "Client")
.WithMany("Orders")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.OrderComponent", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
.WithMany()
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerShopDatabaseImplement.Models.Order", "Order")
.WithMany("Components")
.HasForeignKey("OrderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Component");
b.Navigation("Order");
});
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", "Client")
.WithMany("Supplies")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerShopDatabaseImplement.Models.Order", null)
.WithMany("Supplies")
.HasForeignKey("OrderId");
b.HasOne("ComputerShopDatabaseImplement.Models.EquipmentReceiving", "Receiving")
.WithMany("Supplies")
.HasForeignKey("ReceivingId");
b.Navigation("Client");
b.Navigation("Receiving");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.SupplyOrder", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Order", "Order")
.WithMany()
.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");
});
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("Components");
b.Navigation("Supplies");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b =>
{
b.Navigation("Components");
b.Navigation("Orders");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,104 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ComputerShopDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class component : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_AssemblyOrders_Assemblies_AssemblyId",
table: "AssemblyOrders");
migrationBuilder.DropForeignKey(
name: "FK_Supplies_Components_ComponentId",
table: "Supplies");
migrationBuilder.RenameColumn(
name: "ComponentId",
table: "Supplies",
newName: "OrderId");
migrationBuilder.RenameIndex(
name: "IX_Supplies_ComponentId",
table: "Supplies",
newName: "IX_Supplies_OrderId");
migrationBuilder.RenameColumn(
name: "AssemblyId",
table: "AssemblyOrders",
newName: "ComponentId");
migrationBuilder.RenameIndex(
name: "IX_AssemblyOrders_AssemblyId",
table: "AssemblyOrders",
newName: "IX_AssemblyOrders_ComponentId");
migrationBuilder.AddForeignKey(
name: "FK_AssemblyOrders_Components_ComponentId",
table: "AssemblyOrders",
column: "ComponentId",
principalTable: "Components",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Supplies_Orders_OrderId",
table: "Supplies",
column: "OrderId",
principalTable: "Orders",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_AssemblyOrders_Components_ComponentId",
table: "AssemblyOrders");
migrationBuilder.DropForeignKey(
name: "FK_Supplies_Orders_OrderId",
table: "Supplies");
migrationBuilder.RenameColumn(
name: "OrderId",
table: "Supplies",
newName: "ComponentId");
migrationBuilder.RenameIndex(
name: "IX_Supplies_OrderId",
table: "Supplies",
newName: "IX_Supplies_ComponentId");
migrationBuilder.RenameColumn(
name: "ComponentId",
table: "AssemblyOrders",
newName: "AssemblyId");
migrationBuilder.RenameIndex(
name: "IX_AssemblyOrders_ComponentId",
table: "AssemblyOrders",
newName: "IX_AssemblyOrders_AssemblyId");
migrationBuilder.AddForeignKey(
name: "FK_AssemblyOrders_Assemblies_AssemblyId",
table: "AssemblyOrders",
column: "AssemblyId",
principalTable: "Assemblies",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Supplies_Components_ComponentId",
table: "Supplies",
column: "ComponentId",
principalTable: "Components",
principalColumn: "Id");
}
}
}

View File

@ -0,0 +1,548 @@
// <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("20240517104817_component1")]
partial class component1
{
/// <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.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.OrderComponent", 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>("OrderId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ComponentId");
b.HasIndex("OrderId");
b.ToTable("AssemblyOrders");
});
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("OrderId");
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.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("Components")
.HasForeignKey("SupplyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Component");
b.Navigation("Supply");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.EquipmentReceiving", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", "Client")
.WithMany("EquipmentReceivings")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", "Client")
.WithMany("Orders")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.OrderComponent", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
.WithMany()
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerShopDatabaseImplement.Models.Order", "Order")
.WithMany("Components")
.HasForeignKey("OrderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Component");
b.Navigation("Order");
});
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", "Client")
.WithMany("Supplies")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerShopDatabaseImplement.Models.Order", null)
.WithMany("Supplies")
.HasForeignKey("OrderId");
b.HasOne("ComputerShopDatabaseImplement.Models.EquipmentReceiving", "Receiving")
.WithMany("Supplies")
.HasForeignKey("ReceivingId");
b.Navigation("Client");
b.Navigation("Receiving");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.SupplyOrder", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Order", "Order")
.WithMany()
.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");
});
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("Components");
b.Navigation("Supplies");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b =>
{
b.Navigation("Components");
b.Navigation("Orders");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ComputerShopDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class component1 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@ -0,0 +1,548 @@
// <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("20240517112046_component2")]
partial class component2
{
/// <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.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.OrderComponent", 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>("OrderId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ComponentId");
b.HasIndex("OrderId");
b.ToTable("OrderComponents");
});
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("OrderId");
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.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("Components")
.HasForeignKey("SupplyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Component");
b.Navigation("Supply");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.EquipmentReceiving", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", "Client")
.WithMany("EquipmentReceivings")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", "Client")
.WithMany("Orders")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.OrderComponent", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
.WithMany()
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerShopDatabaseImplement.Models.Order", "Order")
.WithMany("Components")
.HasForeignKey("OrderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Component");
b.Navigation("Order");
});
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", "Client")
.WithMany("Supplies")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerShopDatabaseImplement.Models.Order", null)
.WithMany("Supplies")
.HasForeignKey("OrderId");
b.HasOne("ComputerShopDatabaseImplement.Models.EquipmentReceiving", "Receiving")
.WithMany("Supplies")
.HasForeignKey("ReceivingId");
b.Navigation("Client");
b.Navigation("Receiving");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.SupplyOrder", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Order", "Order")
.WithMany()
.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");
});
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("Components");
b.Navigation("Supplies");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b =>
{
b.Navigation("Components");
b.Navigation("Orders");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,49 @@
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ComputerShopDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class component2 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "OrderComponents",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
OrderId = table.Column<int>(nullable: false),
ComponentId = table.Column<int>(nullable: false),
Count = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_OrderComponents", x => x.Id);
table.ForeignKey(
name: "FK_OrderComponents_Orders_OrderId",
column: x => x.OrderId,
principalTable: "Orders",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_OrderComponents_Components_ComponentId",
column: x => x.ComponentId,
principalTable: "Components",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "OrderComponents");
}
}
}

View File

@ -203,7 +203,7 @@ namespace ComputerShopDatabaseImplement.Migrations
b.ToTable("Orders");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.OrderAssembly", b =>
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.OrderComponent", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
@ -211,7 +211,7 @@ namespace ComputerShopDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("AssemblyId")
b.Property<int>("ComponentId")
.HasColumnType("int");
b.Property<int>("Count")
@ -222,11 +222,11 @@ namespace ComputerShopDatabaseImplement.Migrations
b.HasKey("Id");
b.HasIndex("AssemblyId");
b.HasIndex("ComponentId");
b.HasIndex("OrderId");
b.ToTable("AssemblyOrders");
b.ToTable("OrderComponents");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b =>
@ -282,15 +282,15 @@ namespace ComputerShopDatabaseImplement.Migrations
b.Property<int>("ClientId")
.HasColumnType("int");
b.Property<int?>("ComponentId")
.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");
@ -301,7 +301,7 @@ namespace ComputerShopDatabaseImplement.Migrations
b.HasIndex("ClientId");
b.HasIndex("ComponentId");
b.HasIndex("OrderId");
b.HasIndex("ReceivingId");
@ -405,28 +405,30 @@ namespace ComputerShopDatabaseImplement.Migrations
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
b.HasOne("ComputerShopDatabaseImplement.Models.Client", "Client")
.WithMany("Orders")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.OrderAssembly", b =>
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.OrderComponent", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Assembly", "Assembly")
.WithMany("Orders")
.HasForeignKey("AssemblyId")
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
.WithMany()
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerShopDatabaseImplement.Models.Order", "Order")
.WithMany("Assemblies")
.WithMany("Components")
.HasForeignKey("OrderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Assembly");
b.Navigation("Component");
b.Navigation("Order");
});
@ -452,21 +454,21 @@ namespace ComputerShopDatabaseImplement.Migrations
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
b.HasOne("ComputerShopDatabaseImplement.Models.Client", "Client")
.WithMany("Supplies")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
.WithMany()
.HasForeignKey("ComponentId");
b.HasOne("ComputerShopDatabaseImplement.Models.Order", null)
.WithMany("Supplies")
.HasForeignKey("OrderId");
b.HasOne("ComputerShopDatabaseImplement.Models.EquipmentReceiving", "Receiving")
.WithMany("Supplies")
.HasForeignKey("ReceivingId");
b.Navigation("Component");
b.Navigation("Client");
b.Navigation("Receiving");
});
@ -474,7 +476,7 @@ namespace ComputerShopDatabaseImplement.Migrations
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.SupplyOrder", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Order", "Order")
.WithMany("SupplyOrders")
.WithMany()
.HasForeignKey("OrderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -493,8 +495,6 @@ namespace ComputerShopDatabaseImplement.Migrations
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Assembly", b =>
{
b.Navigation("Components");
b.Navigation("Orders");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Client", b =>
@ -528,9 +528,9 @@ namespace ComputerShopDatabaseImplement.Migrations
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
{
b.Navigation("Assemblies");
b.Navigation("Components");
b.Navigation("SupplyOrders");
b.Navigation("Supplies");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b =>

View File

@ -22,7 +22,6 @@ namespace ComputerShopDatabaseImplement.Models
[Required]
public int ClientId { get; private set; }
private Dictionary<int, (IComponentModel, int)>? _assemblyComponents = null;
[NotMapped]
public Dictionary<int, (IComponentModel, int)> AssemblyComponents
{
get
@ -38,8 +37,6 @@ namespace ComputerShopDatabaseImplement.Models
}
public virtual List<AssemblyComponent> Components { get; set; } = new();
[ForeignKey("AssemblyId")]
public virtual List<OrderAssembly> Orders { get; set; } = new();
public virtual Client Client { get; set; }
public static Assembly Create(ComputerShopDatabase context, AssemblyBindingModel model)
{
@ -55,12 +52,6 @@ namespace ComputerShopDatabaseImplement.Models
Component = context.Components.First(y => y.Id == x.Key),
Count = x.Value.Item2
}).ToList(),
Orders = model.AssemblyOrders.Select(x => new
OrderAssembly
{
Order = context.Orders.First(y => y.Id == x.Key),
Count = x.Value.Item2
}).ToList()
};
}
public void Update(AssemblyBindingModel model)

View File

@ -25,7 +25,7 @@ namespace ComputerShopDatabaseImplement.Models
[ForeignKey("ComponentId")]
public virtual List<Purchase> Purchases { get; set; } = new();
[ForeignKey("ComponentId")]
public virtual List<ComponentSupply> Supplies { get; set; } = new();
public virtual List<ComponentSupply> Supplies { get; set; } = new();
public static Component? Create(ComponentBindingModel model)
{
if (model == null)

View File

@ -23,37 +23,46 @@ namespace ComputerShopDatabaseImplement.Models
public DateTime DateCreate { get; private set; } = DateTime.Now;
public DateTime? DateImplement { get; private set; }
[ForeignKey("OrderId")]
public virtual List<SupplyOrder>? SupplyOrders { get; set; } = new();
[ForeignKey("OrderId")]
public virtual List<OrderAssembly>? Assemblies { get; set; } = new();
private Dictionary<int, (IOrderModel, int)>? _assemblyOrders = null;
private Dictionary<int, (IComponentModel, int)>? _orderComponents = null;
[NotMapped]
public Dictionary<int, (IOrderModel, int)> AssemblyOrders
{
public Dictionary<int, (IComponentModel, int)> OrderComponents
{
get
{
if (_assemblyOrders == null)
if (_orderComponents == null)
{
_assemblyOrders = Assemblies
.ToDictionary(recPC => recPC.AssemblyId, recPC =>
(recPC.Order as IOrderModel, recPC.Count));
_orderComponents = Components
.ToDictionary(recPC => recPC.ComponentId, recPC =>
(recPC.Component as IComponentModel, recPC.Count));
}
return _assemblyOrders;
return _orderComponents;
}
}
[Required]
[ForeignKey("OrderId")]
public virtual List<OrderComponent> Components { get; set; } = new();
[ForeignKey("OrderId")]
public virtual List<Supply>? Supplies { get; set; } = new();
[Required]
public int ClientId { get; set; }
public virtual Client? Client { get; set; }
public static Order? Create(OrderBindingModel model)
public static Order? Create(ComputerShopDatabase context, OrderBindingModel model)
{
if (model == null)
{
return null;
}
var order_comp = model.OrderComponents.Select(x => new
OrderComponent
{
Component = context.Components.First(y => y.Id == x.Key),
Count = x.Value.Item2
}).ToList();
return new Order()
{
Id = model.Id,
@ -61,7 +70,8 @@ namespace ComputerShopDatabaseImplement.Models
Status = model.Status,
DateCreate = model.DateCreate,
DateImplement = model.DateImplement,
ClientId = model.ClientId
ClientId = model.ClientId,
Components = order_comp
};
}
@ -81,6 +91,7 @@ namespace ComputerShopDatabaseImplement.Models
Status = Status,
DateCreate = DateCreate,
DateImplement = DateImplement,
OrderComponents = OrderComponents,
ClientId = ClientId
};
}

View File

@ -7,16 +7,16 @@ using System.Threading.Tasks;
namespace ComputerShopDatabaseImplement.Models
{
internal class OrderAssembly
internal class OrderComponent
{
public int Id { get; set; }
[Required]
public int AssemblyId { get; set; }
[Required]
public int OrderId { get; set; }
public int OrderId { get; set; }
[Required]
public int ComponentId { get; set; }
[Required]
public int Count { get; set; }
public virtual Order Order { get; set; } = new();
public virtual Assembly Assembly { get; set; } = new();
public virtual Component Component { get; set; } = new();
}
}

View File

@ -26,8 +26,6 @@ namespace ComputerShopDatabaseImplement.Models
public virtual Client? Client { get; set; }
public int? ReceivingId { get; set; }
public virtual EquipmentReceiving? Receiving { get; set; }
public int? ComponentId { get; set; }
public virtual Component? Component { get; set; }
private Dictionary<int, IOrderModel>? _supplyOrders =
null;
@ -59,7 +57,6 @@ namespace ComputerShopDatabaseImplement.Models
DateCreate = model.DateCreate,
DateImplement = model.DateImplement,
ReceivingId = model.ReceivingId,
ComponentId = model.ComponentId,
Orders = model.SupplyOrders.Select(x => new
SupplyOrder
{
@ -85,7 +82,6 @@ namespace ComputerShopDatabaseImplement.Models
SupplyOrders = SupplyOrders,
ReceivingId = ReceivingId,
ClientId = ClientId,
ComponentId = ComponentId,
};
public void UpdateOrders(ComputerShopDatabase context, SupplyBindingModel model)
{

View File

@ -7,16 +7,16 @@ using System.Threading.Tasks;
namespace ComputerShopDatabaseImplement.Models
{
internal class SupplyOrder
{
public int Id { get; set; }
[Required]
public int OrderId { get; set; }
[Required]
public int SupplyId { get; set; }
[Required]
public int Count { get; set; }
public virtual Order Order { get; set; } = new();
public virtual Supply Supply { get; set; } = new();
}
internal class SupplyOrder
{
public int Id { get; set; }
[Required]
public int SupplyId { get; set; }
[Required]
public int OrderId { get; set; }
[Required]
public int Count { get; set; }
public virtual Supply Supply { get; set; } = new();
public virtual Order Order { get; set; } = new();
}
}

View File

@ -88,5 +88,6 @@ namespace ComputerShopRestApi.Controllers
throw;
}
}
}
}
}

View File

@ -3,6 +3,9 @@ using ComputerShopContracts.BusinessLogicContracts;
using ComputerShopContracts.SearchModels;
using ComputerShopContracts.StorageContracts;
using ComputerShopContracts.ViewModels;
using ComputerShopDatabaseImplement.Implements;
using DocumentFormat.OpenXml.Bibliography;
using DocumentFormat.OpenXml.Drawing.Charts;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Reflection;
@ -17,10 +20,12 @@ namespace ComputerShopRestApi.Controllers
private readonly IOrderLogic _order;
private readonly IOrderStorage _orderStorage;
public OrderController(ILogger<MainController> logger, IOrderLogic order, ISupplyLogic supply)
public OrderController(ILogger<MainController> logger, IOrderLogic order, ISupplyLogic supply, IOrderStorage orderStorage)
{
_logger = logger;
_order = order;
_orderStorage = orderStorage;
}
[HttpGet]
@ -38,7 +43,22 @@ namespace ComputerShopRestApi.Controllers
}
}
[HttpGet]
[HttpGet]
public List<OrderViewModel>? GetOrder(int id)
{
try
{
return _order.ReadList(new OrderSearchModel { Id = id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения заказа");
throw;
}
}
[HttpGet]
public List<OrderViewModel>? GetOrders(int clientId)
{
try
@ -65,7 +85,7 @@ namespace ComputerShopRestApi.Controllers
throw;
}
}
[HttpDelete]
[HttpPost]
public void DeleteOrder(OrderBindingModel model)
{
try
@ -127,6 +147,7 @@ namespace ComputerShopRestApi.Controllers
try
{
var order = _orderStorage.GetElement(new() { Id = id });
OrderBindingModel model = new OrderBindingModel()
{
Id = id,
@ -138,17 +159,17 @@ namespace ComputerShopRestApi.Controllers
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка изменения закупки");
_logger.LogError(ex, "Ошибка изменения получения техники");
throw;
}
}
[HttpPost]
public void AddAssembly(Tuple<OrderSearchModel, AssemblySearchModel, int> model)
public void AddComponent(Tuple<OrderSearchModel, ComponentSearchModel, int> model)
{
try
{
_order.AddAssembly(model.Item1, model.Item2, model.Item3);
_order.AddComponent(model.Item1, model.Item2, model.Item3);
}
catch (Exception ex)
{
@ -156,5 +177,32 @@ namespace ComputerShopRestApi.Controllers
throw;
}
}
[HttpPost]
public void EditOrder(OrderBindingModel model)
{
try
{
_order.Update(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка обновления заказа.");
throw;
}
}
[HttpGet]
public ComponentViewModel? GetComponentsByOrder(int orderId)
{
try
{
return _orderStorage.GetComponentsByOrder(new OrderSearchModel(){ Id = orderId });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения компонента по orderid={Id}", orderId);
throw;
}
}
}
}

View File

@ -1,11 +1,14 @@
using ComputerShopContracts.BindingModels;
using ComputerShopContracts.SearchModels;
using ComputerShopContracts.ViewModels;
using DocumentFormat.OpenXml.Drawing.Charts;
using DocumentFormat.OpenXml.Office2010.Excel;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Mvc;
using OrdererClientApp.Models;
using System.ComponentModel;
using System.Diagnostics;
using System.Reflection;
namespace OrdererClientApp.Controllers
{
@ -18,7 +21,16 @@ namespace OrdererClientApp.Controllers
_logger = logger;
}
public IActionResult Index()
public IActionResult Index()
{
if (APIClient.Client == null)
{
return Redirect("~/Home/Enter");
}
return View(APIClient.GetRequest<List<EquipmentReceivingViewModel>>($"api/equipmentreceiving/getreceivings?clientId={APIClient.Client.Id}"));
}
public IActionResult Receivings()
{
if (APIClient.Client == null)
{
@ -33,7 +45,7 @@ namespace OrdererClientApp.Controllers
{
return Redirect("~/Home/Enter");
}
return View(APIClient.GetRequest<List<OrderViewModel>>($"api/order/GetOrderList?clientId={APIClient.Client.Id}"));
return View(APIClient.GetRequest<List<OrderViewModel>>($"api/order/getorderlist?clientId={APIClient.Client.Id}"));
}
public IActionResult Supply()
{
@ -76,7 +88,7 @@ namespace OrdererClientApp.Controllers
APIClient.Client.ClientFIO = fio;
APIClient.Client.Email = login;
APIClient.Client.Password = password;
Response.Redirect("Index");
Response.Redirect("Receivings");
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
@ -103,7 +115,7 @@ namespace OrdererClientApp.Controllers
{
throw new Exception("Неверный логин/пароль");
}
Response.Redirect("Index");
Response.Redirect("Receivings");
}
[HttpGet]
@ -142,7 +154,7 @@ namespace OrdererClientApp.Controllers
{
ClientId = APIClient.Client.Id
});
Response.Redirect("Index");
Response.Redirect("Receivings");
}
[HttpPost]
@ -153,82 +165,91 @@ namespace OrdererClientApp.Controllers
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
APIClient.PostRequest($"api/equipmentreceiving/setfinish?id={id}", id);
Response.Redirect("Index");
Response.Redirect("Receivings");
}
[HttpPost]
public void DeleteReceiving(int receiving)
public void DeleteReceiving(int id)
{
if (APIClient.Client == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
APIClient.PostRequest($"api/equipmentreceiving/deletereceiving?id={receiving}", receiving);
Response.Redirect("Index");
APIClient.PostRequest($"api/equipmentreceiving/deletereceiving?id={id}", id);
Response.Redirect("Receivings");
}
[HttpGet]
public IActionResult CreateOrder()
{
return View();
ViewBag.Components = APIClient.GetRequest<List<ComponentViewModel>>($"api/component/getcomponentlist?clientId={APIClient.Client.Id}");
return View();
}
[HttpPost]
public void CreateOrder(int sum)
public void CreateOrder(int sum, int component_id, int amount)
{
if (APIClient.Client == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
APIClient.PostRequest("api/order/createorder", new OrderBindingModel
OrderBindingModel order = new OrderBindingModel
{
ClientId = APIClient.Client.Id,
Sum = sum
});
Response.Redirect("Order");
};
APIClient.PostRequest("api/order/createorder", order);
APIClient.PostRequest("api/order/addcomponent", Tuple.Create(
new OrderSearchModel() { Id = order.Id },
new ComponentSearchModel() { Id = component_id },
amount
));
Response.Redirect("Order");
}
[HttpGet]
public IActionResult DeleteOrder()
{
ViewBag.Components = APIClient.GetRequest<List<ComponentViewModel>>("api/main/getorderlist");
ViewBag.Orders = APIClient.GetRequest<List<OrderViewModel>>($"api/main/getorderlist/?clientId={APIClient.Client.Id}");
return View();
}
[HttpDelete]
public void DeleteOrder(int order)
[HttpPost]
public void DeleteOrder(int id)
{
if (APIClient.Client == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
APIClient.PostRequest("api/order/deleteorder", new ComponentBindingModel
{
Id = order
});
Response.Redirect("Index");
APIClient.PostRequest($"api/order/deleteorder", new ComponentBindingModel
{
Id = id
});
Response.Redirect("Order");
}
public IActionResult AddAssembly()
public IActionResult AddComponent()
{
if (APIClient.Client == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Assemblies = APIClient.GetRequest<List<AssemblyViewModel>>($"api/assembly/getassemblylist?clientId={APIClient.Client.Id}");
ViewBag.Components = APIClient.GetRequest<List<ComponentViewModel>>($"api/component/getcomponentlist?clientId={APIClient.Client.Id}");
ViewBag.Orders = APIClient.GetRequest<List<OrderViewModel>>($"api/order/getorderlist?clientId={APIClient.Client.Id}");
return View();
}
[HttpPost]
public void AddAssembly(int order, int assembly, int amount)
public void AddComponent(int order, int component, int amount)
{
if (APIClient.Client == null)
{
throw new Exception("Необходима авторизация");
}
APIClient.PostRequest("api/order/AddAssembly", Tuple.Create(
APIClient.PostRequest("api/order/AddComponent", Tuple.Create(
new OrderSearchModel() { Id = order },
new AssemblySearchModel() { Id = assembly },
new ComponentSearchModel() { Id = component },
amount
));
Response.Redirect("Order");
@ -242,8 +263,58 @@ namespace OrdererClientApp.Controllers
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
APIClient.PostRequest($"api/order/finishorder?id={id}", id);
Response.Redirect("order");
Response.Redirect("Order");
}
[HttpGet]
public IActionResult EditOrder(int id)
{
if (APIClient.Client == null)
{
return Redirect("~/Home/Enter");
}
var orderViewModel = APIClient.GetRequest<List<OrderViewModel>>($"api/order/getorder?id={id}");
var componentViewModels = APIClient.GetRequest<List<ComponentViewModel>>($"api/order/getcomponentsbyorder?orderid={id}");
ViewBag.Order = orderViewModel;
ViewBag.Components = componentViewModels;
var list = new List<dynamic>
{
orderViewModel,
componentViewModels
};
return View(list);
}
[HttpPost]
public void EditOrder(int order, double cost, int component = -1, int amount = -1)
{
if (APIClient.Client == null)
{
throw new Exception("Необходима авторизация");
}
if (cost < 0)
{
throw new Exception("Стоимость не может быть меньше нуля");
}
if (component >= 0 & amount > 1)
{
APIClient.PostRequest("api/order/AddComponent", Tuple.Create(
new OrderSearchModel() { Id = order },
new ComponentSearchModel() { Id = component },
amount
));
}
APIClient.PostRequest($"api/order/editorder", new OrderBindingModel
{
Id = component,
Sum = cost,
ClientId = APIClient.Client.Id
});
}
[HttpPost]
public void DeliveryOrder(int id)
{
@ -252,7 +323,7 @@ namespace OrdererClientApp.Controllers
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
APIClient.PostRequest($"api/order/deliveryorder?id={id}", id);
Response.Redirect("order");
Response.Redirect("Order");
}
[HttpPost]
public void TakeOrderInWork(int id)
@ -262,7 +333,7 @@ namespace OrdererClientApp.Controllers
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
APIClient.PostRequest($"api/order/takeorderinwork?id={id}", id);
Response.Redirect("order");
Response.Redirect("Order");
}
[HttpPost]

View File

@ -1,32 +0,0 @@
@using ComputerShopContracts.ViewModels;
@using ComputerShopDataModels.Models;
@{
ViewData["Title"] = "Add Assembly To Order";
}
@model Dictionary<int, IAssemblyModel>
<form method="post">
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">Заказ: </label>
<div class="u-input u-input-rectangle">
<select id="order" name="order" class="form-control" asp-items="@(new SelectList(@ViewBag.Orders, "Id", "DateCreate"))"></select>
</div>
</div>
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">Сборка: </label>
<div class="u-input u-input-rectangle">
<select id="assembly" name="assembly" class="form-control" asp-items="@(new SelectList(@ViewBag.Assemblies, "Id", "AssemblyName"))"></select>
</div>
</div>
<div class="row">
<div class="col-4">Количество:</div>
<div class="col-8"><input type="text" name="amount" id="amount" /></div>
</div>
<div class="u-align-right u-form-group u-form-submit u-label-top">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Добавить заказ" class="u-active-custom-color-6 u-border-none u-btn u-btn-submit u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1" /></div>
</div>
</form>

View File

@ -1,17 +1,53 @@

@using ComputerShopContracts.ViewModels;
@using ComputerShopDataModels.Models;
@{
ViewData["Title"] = "CreateOrder";
}
@model Dictionary<int, IComponentModel>
<div class="text-center">
<h2 class="display-4">Создание заказа</h2>
</div>
<form method="post">
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">Комплектующее: </label>
<div class="u-input u-input-rectangle">
<select id="component_id" name="component_id" class="form-control" asp-items="@(new SelectList(@ViewBag.Components, "Id", "ComponentName"))"></select>
</div>
</div>
<div class="row">
<div class="col-4">Цена без учета сборок:</div>
<div class="col-8"><input type="text" name="sum" id="sum" /></div>
<div class="col-4">Количество:</div>
<div class="col-8"><input type="text" name="amount" id="amount" /></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
</div>
</form>
<script>
$('#component_id').on('change', function () {
check();
});
$('#amount').on('change', function () {
check();
});
function check() {
var count = $('#amount').val();
var package = $('#component_id').val();
if (count && package) {
$.ajax({
method: "POST",
url: "/Home/Calc",
data: { count: count, package: package },
success: function (result) {
$("#sum").val(result);
}
});
};
}
</script>

View File

@ -0,0 +1,66 @@
@using ComputerShopContracts.ViewModels;
@using ComputerShopDataModels.Models;
@{
ViewData["Title"] = "OrderEditing";
}
@model IEnumerable<dynamic>
<form method="post">
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">Заказ: </label>
<div class="u-input u-input-rectangle">
asp-items="@(new SelectList(@ViewBag.Order, "Id", "DateCreate"))
</div>
</div>
<tr>
<td>Номер заказа:</td>
</tr>
@foreach (var order in ViewBag.Order)
{
<tr>
<td>@order.Id</td>
</tr>
}
<div class="row">
<div class="col-4">Комплектующие в заказе:</div>
</div>
@if (ViewBag.Components != null)
@foreach (var components in ViewBag.Components)
{
@foreach (var component in components)
{
if (component != null)
{
<tr>
<td>@component.ComponentName</td>
</tr>
}
}
}
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">Добавить комплектующее: </label>
<div class="u-input u-input-rectangle">
<select id="component" name="component" class="form-control" asp-items="@(new SelectList(@ViewBag.Components, "Id", "ComponentName"))"></select>
</div>
</div>
<div class="row">
<div class="col-4">Количество:</div>
<div class="col-8"><input type="text" name="amount" id="amount" /></div>
</div>
<div class="u-align-right u-form-group u-form-submit u-label-top">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Добавить заказ" class="u-active-custom-color-6 u-border-none u-btn u-btn-submit u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1" /></div>
</div>
</form>

View File

@ -23,7 +23,7 @@
<a asp-action="CreateOrder">Создать заказ</a>
</p>
<p>
<a asp-action="AddAssembly">Добавить сборки к заказу</a>
<a asp-action="AddComponent">Добавить компоненты к заказу</a>
</p>
<table class="table">
@ -66,21 +66,25 @@
@Html.DisplayFor(modelItem => item.DateImplement)
</td>
<td>
<form action="TakeOrderInWork" method="post">
<input type="hidden" name="id" value="@item.Id" />
<button type="submit" class="btn btn-outline-dark">Выполняется</button>
</form>
</td>
<td>
<form action="DeliveryOrder" method="post">
<input type="hidden" name="id" value="@item.Id" />
<button type="submit" class="btn btn-outline-dark">Выдан</button>
</form>
<form action="DeliveryOrder" method="post">
<input type="hidden" name="id" value="@item.Id" />
<button type="submit" class="btn btn-outline-dark">Получено</button>
</form>
</td>
<td>
<form action="FinishOrder" method="post">
<form action="EditOrder" method="get">
<input type="hidden" name="id" value="@item.Id" />
<button type="submit" class="btn btn-outline-danger">Изменить</button>
</form>
</td>
<td>
<form action="DeleteOrder" method="post">
<input type="hidden" name="id" value="@item.Id" />
<button type="submit" class="btn btn-outline-dark">Готов</button>
<button type="submit" class="btn btn-outline-danger">Отменить заказ</button>
</form>
</td>
</tr>

View File

@ -21,7 +21,7 @@
<p>
<form action="CreateReceiving" method="post">
<button type="submit" class="btn btn-primary">Создать новое получение</button>
<button type="submit" class="btn btn-primary">Новое получение</button>
</form>
</p>
<table class="table">
@ -64,7 +64,7 @@
</form>
<td>
<form action="DeleteReceiving" method="post">
<input type="hidden" name="receiving" value="@item.Id" />
<input type="hidden" name="id" value="@item.Id" />
<button type="submit" class="btn btn-danger">Отменить</button>
</form>
<td>

View File

@ -44,7 +44,7 @@
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3 container-fluid">
<div class="container-fluid">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Магазин компьютерной техники</a>
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Receivings">Магазин компьютерной техники</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
@ -52,7 +52,7 @@
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Получения компонентов</a>
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Receivings">Получения техники</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Order">Заказы</a>