diff --git a/ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/OrderLogic.cs b/ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/OrderLogic.cs index 71ec7c1..46af4d7 100644 --- a/ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/OrderLogic.cs +++ b/ComputerShopProvider/ComputerShopBusinessLogic/BusinessLogics/OrderLogic.cs @@ -4,6 +4,7 @@ using ComputerShopContracts.SearchModels; using ComputerShopContracts.StorageContracts; using ComputerShopContracts.ViewModels; using ComputerShopDataModels.Enums; +using DocumentFormat.OpenXml.Drawing.Diagrams; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; @@ -17,30 +18,32 @@ namespace ComputerShopBusinessLogic.BusinessLogics { private readonly ILogger _logger; private readonly IOrderStorage _orderStorage; - private readonly IComponentStorage _componentStorage; - public OrderLogic(ILogger logger, IOrderStorage orderStorage, IComponentStorage componentStorage) + private readonly IAssemblyStorage _componentStorage; + public OrderLogic(ILogger logger, IOrderStorage orderStorage, IAssemblyStorage componentStorage) { _logger = logger; _orderStorage = orderStorage; _componentStorage = componentStorage; } - public bool CreateOrder(OrderBindingModel model) + public OrderViewModel? CreateOrder(OrderBindingModel model) { CheckModel(model); if (model.Status != OrderStatus.Неизвестен) { _logger.LogWarning("Order status is incorrect"); - return false; + return null; } model.Status = OrderStatus.Принят; - if (_orderStorage.Insert(model) == null) + var new_order = _orderStorage.Insert(model); + + if (new_order == null) { Console.WriteLine("_orderStorage.Insert(model) == null"); model.Status = OrderStatus.Неизвестен; _logger.LogWarning("Failed to insert order into a storage"); - return false; + return null; } - return true; + return new_order; } public List? ReadList(OrderSearchModel? model) { @@ -54,6 +57,24 @@ namespace ComputerShopBusinessLogic.BusinessLogics _logger.LogInformation("ReadList. Count:{Count}", list.Count); return list; } + + public OrderViewModel? ReadElement(OrderSearchModel? model) + { + _logger.LogInformation("GetElement. Orderid:{ Id}", model?.Id); + var order = new OrderViewModel(); + if (model == null) + order = null; + else + order = _orderStorage.GetElement(model); + + if (order == null) + { + _logger.LogWarning("Get element returned null"); + } + _logger.LogInformation("Read element currect"); + return order; + } + public bool Update(OrderBindingModel model) { CheckModel(model); @@ -64,6 +85,7 @@ namespace ComputerShopBusinessLogic.BusinessLogics } return true; } + public bool Delete(OrderBindingModel model) { CheckModel(model, false); @@ -139,37 +161,42 @@ namespace ComputerShopBusinessLogic.BusinessLogics _logger.LogInformation("Order. OrderID:{Id}. Sum:{ Sum}. ClientId: { ClientId}", model.Id, model.Sum, model.ClientId); } - public bool AddComponent(OrderSearchModel model, ComponentSearchModel componentmodel, int amount) + public bool AddAssembly(OrderSearchModel model, AssemblySearchModel componentmodel, int amount) { - if (model == null) + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + _logger.LogInformation("AddComponentToAssembly. AssemblyName:{AssemblyName}.Id:{ Id}", model.ClientId, model.Id); + var element = _orderStorage.GetElement(model); + var component = _componentStorage.GetElement(componentmodel); + + if (element == null || component == null) + { + return false; + } + + _logger.LogInformation("AddComponentToAssembly find. Id:{Id}", element.Id); + + element.OrderAssemblies[component.Id] = (component, amount); + + + var order_binding = new OrderBindingModel() { - throw new ArgumentNullException(nameof(model)); - } + Id = element.Id, + Status = element.Status, + DateCreate = element.DateCreate, + DateImplement = element.DateImplement, + Sum = element.Sum + component.Price * amount, + ClientId = element.ClientId, + OrderAssemblies = element.OrderAssemblies, + }; - _logger.LogInformation("AddComponentToOrder. AssemblyName:{AssemblyName}.Id:{ Id}", componentmodel.ComponentName, model.Id); - var order = _orderStorage.GetElement(model); - var component = _componentStorage.GetElement(componentmodel); + _orderStorage.Update(order_binding); - if (order == null || component == null) - { - return false; - } - - _logger.LogInformation("AddComponentToOrder find. Id:{Id}", order.Id); - - order.OrderComponents[component.Id] = (component, amount); - - _orderStorage.Update(new() - { - Id = order.Id, - Status = order.Status, - Sum = order.Sum + component.Cost * amount, - ClientId = order.ClientId, - OrderComponents = order.OrderComponents - }); - - return true; - } + return true; + } } } diff --git a/ComputerShopProvider/ComputerShopClientApp/Program.cs b/ComputerShopProvider/ComputerShopClientApp/Program.cs index c870214..7425ef1 100644 --- a/ComputerShopProvider/ComputerShopClientApp/Program.cs +++ b/ComputerShopProvider/ComputerShopClientApp/Program.cs @@ -12,6 +12,7 @@ builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); diff --git a/ComputerShopProvider/ComputerShopContracts/BindingModels/OrderBindingModel.cs b/ComputerShopProvider/ComputerShopContracts/BindingModels/OrderBindingModel.cs index 242a238..2271051 100644 --- a/ComputerShopProvider/ComputerShopContracts/BindingModels/OrderBindingModel.cs +++ b/ComputerShopProvider/ComputerShopContracts/BindingModels/OrderBindingModel.cs @@ -19,7 +19,7 @@ namespace ComputerShopContracts.BindingModels public DateTime? DateImplement { get; set; } public int ClientId { get; set; } - public Dictionary OrderComponents + public Dictionary OrderAssemblies { get; set; diff --git a/ComputerShopProvider/ComputerShopContracts/BusinessLogicContracts/IOrderLogic.cs b/ComputerShopProvider/ComputerShopContracts/BusinessLogicContracts/IOrderLogic.cs index 7c09f84..8557168 100644 --- a/ComputerShopProvider/ComputerShopContracts/BusinessLogicContracts/IOrderLogic.cs +++ b/ComputerShopProvider/ComputerShopContracts/BusinessLogicContracts/IOrderLogic.cs @@ -12,12 +12,13 @@ namespace ComputerShopContracts.BusinessLogicContracts public interface IOrderLogic { List? ReadList(OrderSearchModel? model); - bool CreateOrder(OrderBindingModel model); + OrderViewModel? ReadElement(OrderSearchModel? model); + OrderViewModel? CreateOrder(OrderBindingModel model); bool Update(OrderBindingModel model); bool Delete(OrderBindingModel model); bool TakeOrderInWork(OrderBindingModel model); bool FinishOrder(OrderBindingModel model); bool DeliveryOrder(OrderBindingModel model); - bool AddComponent(OrderSearchModel ordermodel, ComponentSearchModel model, int amount); + bool AddAssembly(OrderSearchModel ordermodel, AssemblySearchModel model, int amount); } } diff --git a/ComputerShopProvider/ComputerShopContracts/StorageContracts/IOrderStorage.cs b/ComputerShopProvider/ComputerShopContracts/StorageContracts/IOrderStorage.cs index f578285..7394939 100644 --- a/ComputerShopProvider/ComputerShopContracts/StorageContracts/IOrderStorage.cs +++ b/ComputerShopProvider/ComputerShopContracts/StorageContracts/IOrderStorage.cs @@ -17,6 +17,6 @@ namespace ComputerShopContracts.StorageContracts OrderViewModel? Insert(OrderBindingModel model); OrderViewModel? Update(OrderBindingModel model); OrderViewModel? Delete(OrderBindingModel model); - ComponentViewModel? GetComponentsByOrder(OrderSearchModel model); + List GetAssembliesByOrder(OrderSearchModel model); } } diff --git a/ComputerShopProvider/ComputerShopContracts/ViewModels/OrderViewModel.cs b/ComputerShopProvider/ComputerShopContracts/ViewModels/OrderViewModel.cs index 9aa5745..7bf899e 100644 --- a/ComputerShopProvider/ComputerShopContracts/ViewModels/OrderViewModel.cs +++ b/ComputerShopProvider/ComputerShopContracts/ViewModels/OrderViewModel.cs @@ -6,6 +6,7 @@ using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; +using Newtonsoft.Json; namespace ComputerShopContracts.ViewModels { @@ -19,7 +20,7 @@ namespace ComputerShopContracts.ViewModels [DisplayName("Дата создания")] public DateTime DateCreate { get; set; } = DateTime.Now; - public Dictionary OrderComponents + public Dictionary OrderAssemblies { get; set; @@ -34,5 +35,14 @@ namespace ComputerShopContracts.ViewModels [DisplayName("ФИО клиента")] public string ClientFIO { get; set; } = string.Empty; + + + public OrderViewModel() { } + + [JsonConstructor] + public OrderViewModel(Dictionary OrderAssemblies) + { + this.OrderAssemblies = OrderAssemblies; + } } } diff --git a/ComputerShopProvider/ComputerShopDataModels/Models/IOrderModel.cs b/ComputerShopProvider/ComputerShopDataModels/Models/IOrderModel.cs index 874b0ba..29dac79 100644 --- a/ComputerShopProvider/ComputerShopDataModels/Models/IOrderModel.cs +++ b/ComputerShopProvider/ComputerShopDataModels/Models/IOrderModel.cs @@ -8,6 +8,6 @@ namespace ComputerShopDataModels.Models OrderStatus Status { get; } DateTime DateCreate { get; } DateTime? DateImplement { get; } - Dictionary OrderComponents { get; } + Dictionary OrderAssemblies { get; } } } diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/ComputerShopDatabase.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/ComputerShopDatabase.cs index 4ec023b..4835e15 100644 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/ComputerShopDatabase.cs +++ b/ComputerShopProvider/ComputerShopDatabaseImplement/ComputerShopDatabase.cs @@ -28,7 +28,7 @@ namespace ComputerShopDatabaseImplement public virtual DbSet SupplyOrders { set; get; } public virtual DbSet EquipmentReceivings { set; get; } public virtual DbSet ComponentSupplies { set; get; } - public virtual DbSet OrderComponents { set; get; } + public virtual DbSet OrderAssemblies { set; get; } public virtual DbSet Clients { set; get; } } } \ No newline at end of file diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Implements/OrderStorage.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Implements/OrderStorage.cs index 4c5d85c..afb115e 100644 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Implements/OrderStorage.cs +++ b/ComputerShopProvider/ComputerShopDatabaseImplement/Implements/OrderStorage.cs @@ -35,7 +35,11 @@ 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 + .Include(x => x.Assemblies) + .ThenInclude(x => x.Assembly) + .FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))? + .GetViewModel; } public List GetFilteredList(OrderSearchModel model) @@ -50,14 +54,14 @@ namespace ComputerShopDatabaseImplement.Implements { return context.Orders .Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo) - .Include(x => x.OrderComponents).Include(x => x.Client) + .Include(x => x.OrderAssemblies).Include(x => x.Client) .Select(x => x.GetViewModel) .ToList(); } return context.Orders - .Include(x => x.Components) - .ThenInclude(x => x.Component) + .Include(x => x.Assemblies) + .ThenInclude(x => x.Assembly) .Where(x => x.ClientId == model.ClientId) .Select(x => x.GetViewModel) .ToList(); @@ -68,7 +72,7 @@ namespace ComputerShopDatabaseImplement.Implements { using var context = new ComputerShopDatabase(); return context.Orders - .Include(x => x.OrderComponents).Include(x => x.Client) + .Include(x => x.OrderAssemblies).Include(x => x.Client) .Select(x => x.GetViewModel) .ToList(); } @@ -90,30 +94,47 @@ namespace ComputerShopDatabaseImplement.Implements public OrderViewModel? Update(OrderBindingModel model) { using var context = new ComputerShopDatabase(); - var order = context.Orders.FirstOrDefault(x => x.Id == model.Id); - if (order == null) - { - return null; - } - order.Update(model); - context.SaveChanges(); - return order.GetViewModel; - } + using var transaction = context.Database.BeginTransaction(); + var order = context.Orders.FirstOrDefault(x => x.Id == model.Id); + try + { + var product = context.Orders.FirstOrDefault(rec => + rec.Id == model.Id); + if (product == null) + { + return null; + } + product.Update(model); + context.SaveChanges(); + product.UpdateAssemblies(context, model); + transaction.Commit(); + return product.GetViewModel; + } + catch + { + transaction.Rollback(); + throw; + } + } - public ComponentViewModel? GetComponentsByOrder(OrderSearchModel model) + public List? GetAssembliesByOrder(OrderSearchModel model) { using var context = new ComputerShopDatabase(); - var order_components = context.OrderComponents.FirstOrDefault(x => x.OrderId == model.Id); + var order_components = context.OrderAssemblies.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) + var components = context.Assemblies.Where(x => x.Id == order_components.AssemblyId) + .Include(x => x.Components) + .ThenInclude(x => x.Component) + .Select(x => x.GetViewModel) + .ToList(); + if (components.Count < 1) { return null; } - return components.GetViewModel; + return components; } } } diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20230519134438_Init.Designer.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20230519134438_Init.Designer.cs deleted file mode 100644 index e631eb1..0000000 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20230519134438_Init.Designer.cs +++ /dev/null @@ -1,532 +0,0 @@ -// -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("20230519134438_Init")] - partial class Init - { - /// - 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("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("AssemblyName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("Price") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("Assemblies"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyComponent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("AssemblyId") - .HasColumnType("int"); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("AssemblyId"); - - b.HasIndex("ComponentId"); - - b.ToTable("AssemblyComponents"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyOrder", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("AssemblyId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("OrderId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("AssemblyId"); - - b.HasIndex("OrderId"); - - b.ToTable("AssemblyOrders"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Client", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientFIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Clients"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Component", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("ComponentName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Cost") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("Components"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ComponentSupply", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("SupplyId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ComponentId"); - - b.HasIndex("SupplyId"); - - b.ToTable("ComponentSupplies"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.EquipmentReceiving", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("Status") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("EquipmentReceivings"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Sum") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("Orders"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("ComponentName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Sum") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.HasIndex("ComponentId"); - - b.ToTable("Purchases"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("OrderId") - .HasColumnType("int"); - - b.Property("ReceivingId") - .HasColumnType("int"); - - b.Property("Status") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.HasIndex("ReceivingId"); - - b.ToTable("Supplies"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.SupplyOrder", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("OrderId") - .HasColumnType("int"); - - b.Property("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"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b => - { - b.HasOne("ComputerShopDatabaseImplement.Models.Client", null) - .WithMany("Orders") - .HasForeignKey("ClientId"); - }); - - 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"); - - b.HasOne("ComputerShopDatabaseImplement.Models.EquipmentReceiving", null) - .WithMany("Supplies") - .HasForeignKey("ReceivingId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - 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 - } - } -} diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20230519134438_Init.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20230519134438_Init.cs deleted file mode 100644 index 6e625e8..0000000 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20230519134438_Init.cs +++ /dev/null @@ -1,400 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace ComputerShopDatabaseImplement.Migrations -{ - /// - public partial class Init : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Clients", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ClientFIO = table.Column(type: "nvarchar(max)", nullable: false), - Email = table.Column(type: "nvarchar(max)", nullable: false), - Password = table.Column(type: "nvarchar(max)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Clients", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Assemblies", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - AssemblyName = table.Column(type: "nvarchar(max)", nullable: false), - Price = table.Column(type: "float", nullable: false), - ClientId = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Assemblies", x => x.Id); - table.ForeignKey( - name: "FK_Assemblies_Clients_ClientId", - column: x => x.ClientId, - principalTable: "Clients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "Components", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ComponentName = table.Column(type: "nvarchar(max)", nullable: false), - Cost = table.Column(type: "float", nullable: false), - ClientId = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Components", x => x.Id); - table.ForeignKey( - name: "FK_Components_Clients_ClientId", - column: x => x.ClientId, - principalTable: "Clients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "EquipmentReceivings", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - DateImplement = table.Column(type: "datetime2", nullable: true), - Status = table.Column(type: "int", nullable: false), - ClientId = table.Column(type: "int", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_EquipmentReceivings", x => x.Id); - table.ForeignKey( - name: "FK_EquipmentReceivings_Clients_ClientId", - column: x => x.ClientId, - principalTable: "Clients", - principalColumn: "Id"); - }); - - migrationBuilder.CreateTable( - name: "Orders", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - Sum = table.Column(type: "float", nullable: false), - Status = table.Column(type: "int", nullable: false), - DateCreate = table.Column(type: "datetime2", nullable: false), - DateImplement = table.Column(type: "datetime2", nullable: true), - ClientId = table.Column(type: "int", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Orders", x => x.Id); - table.ForeignKey( - name: "FK_Orders_Clients_ClientId", - column: x => x.ClientId, - principalTable: "Clients", - principalColumn: "Id"); - }); - - migrationBuilder.CreateTable( - name: "AssemblyComponents", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - AssemblyId = table.Column(type: "int", nullable: false), - ComponentId = table.Column(type: "int", nullable: false), - Count = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AssemblyComponents", x => x.Id); - table.ForeignKey( - name: "FK_AssemblyComponents_Assemblies_AssemblyId", - column: x => x.AssemblyId, - principalTable: "Assemblies", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AssemblyComponents_Components_ComponentId", - column: x => x.ComponentId, - principalTable: "Components", - principalColumn: "Id", - onDelete: ReferentialAction.NoAction); - }); - - migrationBuilder.CreateTable( - name: "Purchases", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ComponentName = table.Column(type: "nvarchar(max)", nullable: false), - ComponentId = table.Column(type: "int", nullable: false), - ClientId = table.Column(type: "int", nullable: false), - Count = table.Column(type: "int", nullable: false), - Sum = table.Column(type: "float", nullable: false), - Status = table.Column(type: "int", nullable: false), - DateCreate = table.Column(type: "datetime2", nullable: false), - DateImplement = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Purchases", x => x.Id); - table.ForeignKey( - name: "FK_Purchases_Clients_ClientId", - column: x => x.ClientId, - principalTable: "Clients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_Purchases_Components_ComponentId", - column: x => x.ComponentId, - principalTable: "Components", - principalColumn: "Id", - onDelete: ReferentialAction.NoAction); - }); - - migrationBuilder.CreateTable( - name: "Supplies", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - Status = table.Column(type: "int", nullable: false), - DateCreate = table.Column(type: "datetime2", nullable: false), - DateImplement = table.Column(type: "datetime2", nullable: true), - OrderId = table.Column(type: "int", nullable: false), - ReceivingId = table.Column(type: "int", nullable: false), - ClientId = table.Column(type: "int", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Supplies", x => x.Id); - table.ForeignKey( - name: "FK_Supplies_Clients_ClientId", - column: x => x.ClientId, - principalTable: "Clients", - principalColumn: "Id"); - table.ForeignKey( - name: "FK_Supplies_EquipmentReceivings_ReceivingId", - column: x => x.ReceivingId, - principalTable: "EquipmentReceivings", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AssemblyOrders", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - AssemblyId = table.Column(type: "int", nullable: false), - OrderId = table.Column(type: "int", nullable: false), - Count = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AssemblyOrders", x => x.Id); - table.ForeignKey( - name: "FK_AssemblyOrders_Assemblies_AssemblyId", - column: x => x.AssemblyId, - principalTable: "Assemblies", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AssemblyOrders_Orders_OrderId", - column: x => x.OrderId, - principalTable: "Orders", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "ComponentSupplies", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - SupplyId = table.Column(type: "int", nullable: false), - ComponentId = table.Column(type: "int", nullable: false), - Count = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_ComponentSupplies", x => x.Id); - table.ForeignKey( - name: "FK_ComponentSupplies_Components_ComponentId", - column: x => x.ComponentId, - principalTable: "Components", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_ComponentSupplies_Supplies_SupplyId", - column: x => x.SupplyId, - principalTable: "Supplies", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "SupplyOrders", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - OrderId = table.Column(type: "int", nullable: false), - SupplyId = table.Column(type: "int", nullable: false), - Count = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_SupplyOrders", x => x.Id); - table.ForeignKey( - name: "FK_SupplyOrders_Orders_OrderId", - column: x => x.OrderId, - principalTable: "Orders", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_SupplyOrders_Supplies_SupplyId", - column: x => x.SupplyId, - principalTable: "Supplies", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_Assemblies_ClientId", - table: "Assemblies", - column: "ClientId"); - - migrationBuilder.CreateIndex( - name: "IX_AssemblyComponents_AssemblyId", - table: "AssemblyComponents", - column: "AssemblyId"); - - migrationBuilder.CreateIndex( - name: "IX_AssemblyComponents_ComponentId", - table: "AssemblyComponents", - column: "ComponentId"); - - migrationBuilder.CreateIndex( - name: "IX_AssemblyOrders_AssemblyId", - table: "AssemblyOrders", - column: "AssemblyId"); - - migrationBuilder.CreateIndex( - name: "IX_AssemblyOrders_OrderId", - table: "AssemblyOrders", - column: "OrderId"); - - migrationBuilder.CreateIndex( - name: "IX_Components_ClientId", - table: "Components", - column: "ClientId"); - - migrationBuilder.CreateIndex( - name: "IX_ComponentSupplies_ComponentId", - table: "ComponentSupplies", - column: "ComponentId"); - - migrationBuilder.CreateIndex( - name: "IX_ComponentSupplies_SupplyId", - table: "ComponentSupplies", - column: "SupplyId"); - - migrationBuilder.CreateIndex( - name: "IX_EquipmentReceivings_ClientId", - table: "EquipmentReceivings", - column: "ClientId"); - - migrationBuilder.CreateIndex( - name: "IX_Orders_ClientId", - table: "Orders", - column: "ClientId"); - - migrationBuilder.CreateIndex( - name: "IX_Purchases_ClientId", - table: "Purchases", - column: "ClientId"); - - migrationBuilder.CreateIndex( - name: "IX_Purchases_ComponentId", - table: "Purchases", - column: "ComponentId"); - - migrationBuilder.CreateIndex( - name: "IX_Supplies_ClientId", - table: "Supplies", - column: "ClientId"); - - migrationBuilder.CreateIndex( - name: "IX_Supplies_ReceivingId", - table: "Supplies", - column: "ReceivingId"); - - migrationBuilder.CreateIndex( - name: "IX_SupplyOrders_OrderId", - table: "SupplyOrders", - column: "OrderId"); - - migrationBuilder.CreateIndex( - name: "IX_SupplyOrders_SupplyId", - table: "SupplyOrders", - column: "SupplyId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "AssemblyComponents"); - - migrationBuilder.DropTable( - name: "AssemblyOrders"); - - migrationBuilder.DropTable( - name: "ComponentSupplies"); - - migrationBuilder.DropTable( - name: "Purchases"); - - migrationBuilder.DropTable( - name: "SupplyOrders"); - - migrationBuilder.DropTable( - name: "Assemblies"); - - migrationBuilder.DropTable( - name: "Components"); - - migrationBuilder.DropTable( - name: "Orders"); - - migrationBuilder.DropTable( - name: "Supplies"); - - migrationBuilder.DropTable( - name: "EquipmentReceivings"); - - migrationBuilder.DropTable( - name: "Clients"); - } - } -} diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20230520051723_fix.Designer.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20230520051723_fix.Designer.cs deleted file mode 100644 index 8ff39b8..0000000 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20230520051723_fix.Designer.cs +++ /dev/null @@ -1,540 +0,0 @@ -// -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 - { - /// - 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("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("AssemblyName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("Price") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("Assemblies"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyComponent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("AssemblyId") - .HasColumnType("int"); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("AssemblyId"); - - b.HasIndex("ComponentId"); - - b.ToTable("AssemblyComponents"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyOrder", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("AssemblyId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("OrderId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("AssemblyId"); - - b.HasIndex("OrderId"); - - b.ToTable("AssemblyOrders"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Client", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientFIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Clients"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Component", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("ComponentName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Cost") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("Components"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ComponentSupply", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("SupplyId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ComponentId"); - - b.HasIndex("SupplyId"); - - b.ToTable("ComponentSupplies"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.EquipmentReceiving", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("Status") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("EquipmentReceivings"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Sum") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("Orders"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("ComponentName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Sum") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.HasIndex("ComponentId"); - - b.ToTable("Purchases"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("OrderId") - .HasColumnType("int"); - - b.Property("ReceivingId") - .HasColumnType("int"); - - b.Property("Status") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.HasIndex("ReceivingId"); - - b.ToTable("Supplies"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.SupplyOrder", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("OrderId") - .HasColumnType("int"); - - b.Property("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 - } - } -} diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20230520051723_fix.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20230520051723_fix.cs deleted file mode 100644 index 370d04a..0000000 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20230520051723_fix.cs +++ /dev/null @@ -1,141 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace ComputerShopDatabaseImplement.Migrations -{ - /// - public partial class fix : Migration - { - /// - 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( - name: "ClientId", - table: "Supplies", - type: "int", - nullable: false, - defaultValue: 0, - oldClrType: typeof(int), - oldType: "int", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "ClientId", - table: "Orders", - type: "int", - nullable: false, - defaultValue: 0, - oldClrType: typeof(int), - oldType: "int", - oldNullable: true); - - migrationBuilder.AlterColumn( - 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); - } - - /// - 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( - name: "ClientId", - table: "Supplies", - type: "int", - nullable: true, - oldClrType: typeof(int), - oldType: "int"); - - migrationBuilder.AlterColumn( - name: "ClientId", - table: "Orders", - type: "int", - nullable: true, - oldClrType: typeof(int), - oldType: "int"); - - migrationBuilder.AlterColumn( - 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"); - } - } -} diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20230524135850_ordermig.Designer.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20230524135850_ordermig.Designer.cs deleted file mode 100644 index 1f73480..0000000 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20230524135850_ordermig.Designer.cs +++ /dev/null @@ -1,538 +0,0 @@ -// -using System; -using ComputerShopDatabaseImplement; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace ComputerShopDatabaseImplement.Migrations -{ - [DbContext(typeof(ComputerShopDatabase))] - [Migration("20230524135850_ordermig")] - partial class ordermig - { - /// - 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("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("AssemblyName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("Price") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("Assemblies"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyComponent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("AssemblyId") - .HasColumnType("int"); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("AssemblyId"); - - b.HasIndex("ComponentId"); - - b.ToTable("AssemblyComponents"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyOrder", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("AssemblyId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("OrderId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("AssemblyId"); - - b.HasIndex("OrderId"); - - b.ToTable("AssemblyOrders"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Client", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientFIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Clients"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Component", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("ComponentName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Cost") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("Components"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ComponentSupply", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("SupplyId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ComponentId"); - - b.HasIndex("SupplyId"); - - b.ToTable("ComponentSupplies"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.EquipmentReceiving", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("Status") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("EquipmentReceivings"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Sum") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("Orders"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("ComponentName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Sum") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.HasIndex("ComponentId"); - - b.ToTable("Purchases"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("ReceivingId") - .IsRequired() - .HasColumnType("int"); - - b.Property("Status") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.HasIndex("ReceivingId"); - - b.ToTable("Supplies"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.SupplyOrder", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("OrderId") - .HasColumnType("int"); - - b.Property("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 - } - } -} diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20230524135850_ordermig.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20230524135850_ordermig.cs deleted file mode 100644 index 5f5b121..0000000 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20230524135850_ordermig.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace ComputerShopDatabaseImplement.Migrations -{ - /// - public partial class ordermig : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "OrderId", - table: "Supplies"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "OrderId", - table: "Supplies", - type: "int", - nullable: false, - defaultValue: 0); - } - } -} diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20231007140302_fix2.Designer.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20231007140302_fix2.Designer.cs deleted file mode 100644 index f0b6b63..0000000 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20231007140302_fix2.Designer.cs +++ /dev/null @@ -1,546 +0,0 @@ -// -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("20231007140302_fix2")] - partial class fix2 - { - /// - 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("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("AssemblyName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("Price") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("Assemblies"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyComponent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("AssemblyId") - .HasColumnType("int"); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("AssemblyId"); - - b.HasIndex("ComponentId"); - - b.ToTable("AssemblyComponents"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Client", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientFIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Clients"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Component", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("ComponentName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Cost") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("Components"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ComponentSupply", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("SupplyId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ComponentId"); - - b.HasIndex("SupplyId"); - - b.ToTable("ComponentSupplies"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.EquipmentReceiving", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("Status") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("EquipmentReceivings"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Sum") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("Orders"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.OrderAssembly", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("AssemblyId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("OrderId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("AssemblyId"); - - b.HasIndex("OrderId"); - - b.ToTable("AssemblyOrders"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("ComponentName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Sum") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.HasIndex("ComponentId"); - - b.ToTable("Purchases"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("ReceivingId") - .HasColumnType("int"); - - b.Property("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("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("OrderId") - .HasColumnType("int"); - - b.Property("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", 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.OrderAssembly", 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.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.Component", "Component") - .WithMany() - .HasForeignKey("ComponentId"); - - b.HasOne("ComputerShopDatabaseImplement.Models.EquipmentReceiving", "Receiving") - .WithMany("Supplies") - .HasForeignKey("ReceivingId"); - - 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"); - - 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("Components"); - - b.Navigation("Orders"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20231007140302_fix2.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20231007140302_fix2.cs deleted file mode 100644 index a348e01..0000000 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20231007140302_fix2.cs +++ /dev/null @@ -1,89 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace ComputerShopDatabaseImplement.Migrations -{ - /// - public partial class fix2 : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Supplies_EquipmentReceivings_ReceivingId", - table: "Supplies"); - - migrationBuilder.AlterColumn( - name: "ReceivingId", - table: "Supplies", - type: "int", - nullable: true, - oldClrType: typeof(int), - oldType: "int"); - - migrationBuilder.AddColumn( - name: "ComponentId", - table: "Supplies", - type: "int", - nullable: true); - - migrationBuilder.CreateIndex( - name: "IX_Supplies_ComponentId", - table: "Supplies", - column: "ComponentId"); - - migrationBuilder.AddForeignKey( - name: "FK_Supplies_Components_ComponentId", - table: "Supplies", - column: "ComponentId", - principalTable: "Components", - principalColumn: "Id"); - - migrationBuilder.AddForeignKey( - name: "FK_Supplies_EquipmentReceivings_ReceivingId", - table: "Supplies", - column: "ReceivingId", - principalTable: "EquipmentReceivings", - principalColumn: "Id"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Supplies_Components_ComponentId", - table: "Supplies"); - - migrationBuilder.DropForeignKey( - name: "FK_Supplies_EquipmentReceivings_ReceivingId", - table: "Supplies"); - - migrationBuilder.DropIndex( - name: "IX_Supplies_ComponentId", - table: "Supplies"); - - migrationBuilder.DropColumn( - name: "ComponentId", - table: "Supplies"); - - migrationBuilder.AlterColumn( - name: "ReceivingId", - table: "Supplies", - type: "int", - nullable: false, - defaultValue: 0, - oldClrType: typeof(int), - oldType: "int", - oldNullable: true); - - migrationBuilder.AddForeignKey( - name: "FK_Supplies_EquipmentReceivings_ReceivingId", - table: "Supplies", - column: "ReceivingId", - principalTable: "EquipmentReceivings", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } - } -} diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20231202000001_nullable.Designer.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20231202000001_nullable.Designer.cs deleted file mode 100644 index b8b0e10..0000000 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20231202000001_nullable.Designer.cs +++ /dev/null @@ -1,548 +0,0 @@ -// -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("20231202000001_nullable")] - partial class nullable - { - /// - 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("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("AssemblyName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("Price") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("Assemblies"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyComponent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("AssemblyId") - .HasColumnType("int"); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("AssemblyId"); - - b.HasIndex("ComponentId"); - - b.ToTable("AssemblyComponents"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Client", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientFIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Clients"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Component", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("ComponentName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Cost") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("Components"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ComponentSupply", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("SupplyId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ComponentId"); - - b.HasIndex("SupplyId"); - - b.ToTable("ComponentSupplies"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.EquipmentReceiving", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("Status") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("EquipmentReceivings"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Sum") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("Orders"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.OrderAssembly", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("AssemblyId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("OrderId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("AssemblyId"); - - b.HasIndex("OrderId"); - - b.ToTable("AssemblyOrders"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("ComponentName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Sum") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.HasIndex("ComponentId"); - - b.ToTable("Purchases"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("ReceivingId") - .HasColumnType("int"); - - b.Property("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("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("OrderId") - .HasColumnType("int"); - - b.Property("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", null) - .WithMany("Orders") - .HasForeignKey("ClientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.OrderAssembly", 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.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.Component", "Component") - .WithMany() - .HasForeignKey("ComponentId"); - - b.HasOne("ComputerShopDatabaseImplement.Models.EquipmentReceiving", "Receiving") - .WithMany("Supplies") - .HasForeignKey("ReceivingId"); - - 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"); - - 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("Components"); - - b.Navigation("Orders"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20231202000001_nullable.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20231202000001_nullable.cs deleted file mode 100644 index a69f893..0000000 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20231202000001_nullable.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace ComputerShopDatabaseImplement.Migrations -{ - /// - public partial class nullable : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - - } - } -} diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20240516194435_1605.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20240516194435_1605.cs deleted file mode 100644 index 6b64a64..0000000 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20240516194435_1605.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace ComputerShopDatabaseImplement.Migrations -{ - /// - public partial class _1605 : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - - } - } -} diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20240517100456_component.Designer.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20240517100456_component.Designer.cs deleted file mode 100644 index 7664f49..0000000 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20240517100456_component.Designer.cs +++ /dev/null @@ -1,548 +0,0 @@ -// -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 - { - /// - 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("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("AssemblyName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("Price") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("Assemblies"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyComponent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("AssemblyId") - .HasColumnType("int"); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("AssemblyId"); - - b.HasIndex("ComponentId"); - - b.ToTable("AssemblyComponents"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Client", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientFIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Clients"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Component", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("ComponentName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Cost") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("Components"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ComponentSupply", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("SupplyId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ComponentId"); - - b.HasIndex("SupplyId"); - - b.ToTable("ComponentSupplies"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.EquipmentReceiving", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("Status") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("EquipmentReceivings"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Sum") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("Orders"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.OrderComponent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("OrderId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ComponentId"); - - b.HasIndex("OrderId"); - - b.ToTable("AssemblyOrders"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("ComponentName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Sum") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.HasIndex("ComponentId"); - - b.ToTable("Purchases"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("OrderId") - .HasColumnType("int"); - - b.Property("ReceivingId") - .HasColumnType("int"); - - b.Property("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("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("OrderId") - .HasColumnType("int"); - - b.Property("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 - } - } -} diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20240517100456_component.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20240517100456_component.cs deleted file mode 100644 index c7fa5f8..0000000 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20240517100456_component.cs +++ /dev/null @@ -1,104 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace ComputerShopDatabaseImplement.Migrations -{ - /// - public partial class component : Migration - { - /// - 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"); - } - - /// - 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"); - } - } -} diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20240517104817_component1.Designer.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20240517104817_component1.Designer.cs deleted file mode 100644 index 9eba960..0000000 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20240517104817_component1.Designer.cs +++ /dev/null @@ -1,548 +0,0 @@ -// -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 - { - /// - 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("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("AssemblyName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("Price") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("Assemblies"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyComponent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("AssemblyId") - .HasColumnType("int"); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("AssemblyId"); - - b.HasIndex("ComponentId"); - - b.ToTable("AssemblyComponents"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Client", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientFIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Clients"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Component", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("ComponentName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Cost") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("Components"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ComponentSupply", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("SupplyId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ComponentId"); - - b.HasIndex("SupplyId"); - - b.ToTable("ComponentSupplies"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.EquipmentReceiving", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("Status") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("EquipmentReceivings"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Sum") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("Orders"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.OrderComponent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("OrderId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ComponentId"); - - b.HasIndex("OrderId"); - - b.ToTable("AssemblyOrders"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("ComponentName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Sum") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.HasIndex("ComponentId"); - - b.ToTable("Purchases"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("OrderId") - .HasColumnType("int"); - - b.Property("ReceivingId") - .HasColumnType("int"); - - b.Property("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("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("OrderId") - .HasColumnType("int"); - - b.Property("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 - } - } -} diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20240517104817_component1.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20240517104817_component1.cs deleted file mode 100644 index de0ce86..0000000 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20240517104817_component1.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace ComputerShopDatabaseImplement.Migrations -{ - /// - public partial class component1 : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - - } - } -} diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20240517112046_component2.Designer.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20240517112046_component2.Designer.cs deleted file mode 100644 index 04c5bd8..0000000 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20240517112046_component2.Designer.cs +++ /dev/null @@ -1,548 +0,0 @@ -// -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 - { - /// - 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("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("AssemblyName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("Price") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("Assemblies"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyComponent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("AssemblyId") - .HasColumnType("int"); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("AssemblyId"); - - b.HasIndex("ComponentId"); - - b.ToTable("AssemblyComponents"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Client", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientFIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Clients"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Component", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("ComponentName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Cost") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("Components"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ComponentSupply", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("SupplyId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ComponentId"); - - b.HasIndex("SupplyId"); - - b.ToTable("ComponentSupplies"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.EquipmentReceiving", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("Status") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("EquipmentReceivings"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Sum") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("Orders"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.OrderComponent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("OrderId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ComponentId"); - - b.HasIndex("OrderId"); - - b.ToTable("OrderComponents"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("ComponentName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Sum") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.HasIndex("ComponentId"); - - b.ToTable("Purchases"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("OrderId") - .HasColumnType("int"); - - b.Property("ReceivingId") - .HasColumnType("int"); - - b.Property("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("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("OrderId") - .HasColumnType("int"); - - b.Property("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 - } - } -} diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20240517112046_component2.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20240517112046_component2.cs deleted file mode 100644 index 6d8ae03..0000000 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20240517112046_component2.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace ComputerShopDatabaseImplement.Migrations -{ - /// - public partial class component2 : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "OrderComponents", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), - OrderId = table.Column(nullable: false), - ComponentId = table.Column(nullable: false), - Count = table.Column(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); - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "OrderComponents"); - } - } -} diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20240516194435_1605.Designer.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20241126221352_OrderAssemblies.Designer.cs similarity index 97% rename from ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20240516194435_1605.Designer.cs rename to ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20241126221352_OrderAssemblies.Designer.cs index 6ace50d..f6765ee 100644 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20240516194435_1605.Designer.cs +++ b/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20241126221352_OrderAssemblies.Designer.cs @@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace ComputerShopDatabaseImplement.Migrations { [DbContext(typeof(ComputerShopDatabase))] - [Migration("20240516194435_1605")] - partial class _1605 + [Migration("20241126221352_OrderAssemblies")] + partial class OrderAssemblies { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -229,7 +229,7 @@ namespace ComputerShopDatabaseImplement.Migrations b.HasIndex("OrderId"); - b.ToTable("AssemblyOrders"); + b.ToTable("OrderAssemblies"); }); modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b => @@ -285,15 +285,15 @@ namespace ComputerShopDatabaseImplement.Migrations b.Property("ClientId") .HasColumnType("int"); - b.Property("ComponentId") - .HasColumnType("int"); - b.Property("DateCreate") .HasColumnType("datetime2"); b.Property("DateImplement") .HasColumnType("datetime2"); + b.Property("OrderId") + .HasColumnType("int"); + b.Property("ReceivingId") .HasColumnType("int"); @@ -304,7 +304,7 @@ namespace ComputerShopDatabaseImplement.Migrations b.HasIndex("ClientId"); - b.HasIndex("ComponentId"); + b.HasIndex("OrderId"); b.HasIndex("ReceivingId"); @@ -463,9 +463,9 @@ namespace ComputerShopDatabaseImplement.Migrations .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") @@ -473,15 +473,13 @@ namespace ComputerShopDatabaseImplement.Migrations b.Navigation("Client"); - b.Navigation("Component"); - b.Navigation("Receiving"); }); modelBuilder.Entity("ComputerShopDatabaseImplement.Models.SupplyOrder", b => { b.HasOne("ComputerShopDatabaseImplement.Models.Order", "Order") - .WithMany("SupplyOrders") + .WithMany() .HasForeignKey("OrderId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -535,7 +533,7 @@ namespace ComputerShopDatabaseImplement.Migrations { b.Navigation("Assemblies"); - b.Navigation("SupplyOrders"); + b.Navigation("Supplies"); }); modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b => diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20241126221352_OrderAssemblies.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20241126221352_OrderAssemblies.cs new file mode 100644 index 0000000..49bf05f --- /dev/null +++ b/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20241126221352_OrderAssemblies.cs @@ -0,0 +1,98 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace ComputerShopDatabaseImplement.Migrations +{ + /// + public partial class OrderAssemblies : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "OrderComponents"); + + migrationBuilder.CreateTable( + name: "OrderAssemblies", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + OrderId = table.Column(type: "int", nullable: false), + AssemblyId = table.Column(type: "int", nullable: false), + Count = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_OrderAssemblies", x => x.Id); + table.ForeignKey( + name: "FK_OrderAssemblies_Assemblies_AssemblyId", + column: x => x.AssemblyId, + principalTable: "Assemblies", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_OrderAssemblies_Orders_OrderId", + column: x => x.OrderId, + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_OrderAssemblies_AssemblyId", + table: "OrderAssemblies", + column: "AssemblyId"); + + migrationBuilder.CreateIndex( + name: "IX_OrderAssemblies_OrderId", + table: "OrderAssemblies", + column: "OrderId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "OrderAssemblies"); + + migrationBuilder.CreateTable( + name: "OrderComponents", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ComponentId = table.Column(type: "int", nullable: false), + OrderId = table.Column(type: "int", nullable: false), + Count = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_OrderComponents", x => x.Id); + table.ForeignKey( + name: "FK_OrderComponents_Components_ComponentId", + column: x => x.ComponentId, + principalTable: "Components", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_OrderComponents_Orders_OrderId", + column: x => x.OrderId, + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_OrderComponents_ComponentId", + table: "OrderComponents", + column: "ComponentId"); + + migrationBuilder.CreateIndex( + name: "IX_OrderComponents_OrderId", + table: "OrderComponents", + column: "OrderId"); + } + } +} diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/ComputerShopDatabaseModelSnapshot.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/ComputerShopDatabaseModelSnapshot.cs index 6c64199..c54c066 100644 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/ComputerShopDatabaseModelSnapshot.cs +++ b/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/ComputerShopDatabaseModelSnapshot.cs @@ -203,7 +203,7 @@ namespace ComputerShopDatabaseImplement.Migrations b.ToTable("Orders"); }); - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.OrderComponent", b => + modelBuilder.Entity("ComputerShopDatabaseImplement.Models.OrderAssembly", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -211,7 +211,7 @@ namespace ComputerShopDatabaseImplement.Migrations SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - b.Property("ComponentId") + b.Property("AssemblyId") .HasColumnType("int"); b.Property("Count") @@ -222,11 +222,11 @@ namespace ComputerShopDatabaseImplement.Migrations b.HasKey("Id"); - b.HasIndex("ComponentId"); + b.HasIndex("AssemblyId"); b.HasIndex("OrderId"); - b.ToTable("OrderComponents"); + b.ToTable("OrderAssemblies"); }); modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b => @@ -414,21 +414,21 @@ namespace ComputerShopDatabaseImplement.Migrations b.Navigation("Client"); }); - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.OrderComponent", b => + modelBuilder.Entity("ComputerShopDatabaseImplement.Models.OrderAssembly", b => { - b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component") + b.HasOne("ComputerShopDatabaseImplement.Models.Assembly", "Assembly") .WithMany() - .HasForeignKey("ComponentId") + .HasForeignKey("AssemblyId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.HasOne("ComputerShopDatabaseImplement.Models.Order", "Order") - .WithMany("Components") + .WithMany("Assemblies") .HasForeignKey("OrderId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.Navigation("Component"); + b.Navigation("Assembly"); b.Navigation("Order"); }); @@ -528,7 +528,7 @@ namespace ComputerShopDatabaseImplement.Migrations modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b => { - b.Navigation("Components"); + b.Navigation("Assemblies"); b.Navigation("Supplies"); }); diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Models/Order.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Models/Order.cs index 05e3b43..0834a24 100644 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Models/Order.cs +++ b/ComputerShopProvider/ComputerShopDatabaseImplement/Models/Order.cs @@ -25,24 +25,24 @@ namespace ComputerShopDatabaseImplement.Models public DateTime? DateImplement { get; private set; } [ForeignKey("OrderId")] - private Dictionary? _orderComponents = null; + private Dictionary? _orderAssembliess = null; - public Dictionary OrderComponents + public Dictionary OrderAssemblies { get { - if (_orderComponents == null) + if (_orderAssembliess == null) { - _orderComponents = Components - .ToDictionary(recPC => recPC.ComponentId, recPC => - (recPC.Component as IComponentModel, recPC.Count)); + _orderAssembliess = Assemblies + .ToDictionary(recPC => recPC.AssemblyId, recPC => + (recPC.Assembly as IAssemblyModel, recPC.Count)); } - return _orderComponents; + return _orderAssembliess; } } [ForeignKey("OrderId")] - public virtual List Components { get; set; } = new(); + public virtual List Assemblies { get; set; } = new(); [ForeignKey("OrderId")] public virtual List? Supplies { get; set; } = new(); @@ -55,10 +55,10 @@ namespace ComputerShopDatabaseImplement.Models { return null; } - var order_comp = model.OrderComponents.Select(x => new - OrderComponent + var order_comp = model.OrderAssemblies.Select(x => new + OrderAssembly { - Component = context.Components.First(y => y.Id == x.Key), + Assembly = context.Assemblies.First(y => y.Id == x.Key), Count = x.Value.Item2 }).ToList(); @@ -71,7 +71,7 @@ namespace ComputerShopDatabaseImplement.Models DateCreate = model.DateCreate, DateImplement = model.DateImplement, ClientId = model.ClientId, - Components = order_comp + Assemblies = order_comp }; } @@ -83,6 +83,7 @@ namespace ComputerShopDatabaseImplement.Models } Status = model.Status; DateImplement = model.DateImplement; + Sum = model.Sum; } public OrderViewModel GetViewModel => new() { @@ -91,8 +92,38 @@ namespace ComputerShopDatabaseImplement.Models Status = Status, DateCreate = DateCreate, DateImplement = DateImplement, - OrderComponents = OrderComponents, + OrderAssemblies = OrderAssemblies, ClientId = ClientId }; - } + + public void UpdateAssemblies(ComputerShopDatabase context, OrderBindingModel model) + { + var assemblyComponents = context.AssemblyComponents.Where(rec => rec.Id == model.Id).ToList(); + if (assemblyComponents != null && assemblyComponents.Count > 0) + { // удалили те, которых нет в модели + context.AssemblyComponents.RemoveRange(assemblyComponents.Where(rec + => !model.OrderAssemblies.ContainsKey(rec.AssemblyId))); + context.SaveChanges(); + // обновили количество у существующих записей + foreach (var updateComponent in assemblyComponents) + { + updateComponent.Count = model.OrderAssemblies[updateComponent.AssemblyId].Item2; + model.OrderAssemblies.Remove(updateComponent.AssemblyId); + } + context.SaveChanges(); + } + var assembly = context.Orders.First(x => x.Id == Id); + foreach (var pc in model.OrderAssemblies) + { + context.OrderAssemblies.Add(new OrderAssembly + { + Order = assembly, + Assembly = context.Assemblies.First(x => x.Id == pc.Key), + Count = pc.Value.Item2 + }); + context.SaveChanges(); + } + _orderAssembliess = null; + } + } } diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Models/OrderComponent.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Models/OrderAssembly.cs similarity index 76% rename from ComputerShopProvider/ComputerShopDatabaseImplement/Models/OrderComponent.cs rename to ComputerShopProvider/ComputerShopDatabaseImplement/Models/OrderAssembly.cs index c004464..55683d4 100644 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Models/OrderComponent.cs +++ b/ComputerShopProvider/ComputerShopDatabaseImplement/Models/OrderAssembly.cs @@ -7,16 +7,16 @@ using System.Threading.Tasks; namespace ComputerShopDatabaseImplement.Models { - internal class OrderComponent + internal class OrderAssembly { public int Id { get; set; } [Required] public int OrderId { get; set; } [Required] - public int ComponentId { get; set; } + public int AssemblyId { get; set; } [Required] public int Count { get; set; } public virtual Order Order { get; set; } = new(); - public virtual Component Component { get; set; } = new(); + public virtual Assembly Assembly { get; set; } = new(); } } diff --git a/ComputerShopProvider/ComputerShopRestApi/Controllers/AssemblyController.cs b/ComputerShopProvider/ComputerShopRestApi/Controllers/AssemblyController.cs index bf97d08..f5d3ef0 100644 --- a/ComputerShopProvider/ComputerShopRestApi/Controllers/AssemblyController.cs +++ b/ComputerShopProvider/ComputerShopRestApi/Controllers/AssemblyController.cs @@ -25,10 +25,11 @@ namespace ComputerShopRestApi.Controllers { try { - return _assembly.ReadList(new AssemblySearchModel + var list = _assembly.ReadList(new AssemblySearchModel { ClientId = clientId, }); + return list; } catch (Exception ex) { diff --git a/ComputerShopProvider/ComputerShopRestApi/Controllers/OrderController.cs b/ComputerShopProvider/ComputerShopRestApi/Controllers/OrderController.cs index 444d8a8..0ce83fc 100644 --- a/ComputerShopProvider/ComputerShopRestApi/Controllers/OrderController.cs +++ b/ComputerShopProvider/ComputerShopRestApi/Controllers/OrderController.cs @@ -44,12 +44,14 @@ namespace ComputerShopRestApi.Controllers } [HttpGet] - public List? GetOrder(int id) + public OrderViewModel? GetOrder(int id) { try { - return _order.ReadList(new OrderSearchModel { Id = id }); + var order = new OrderViewModel(); + order = _order.ReadElement(new OrderSearchModel { Id = id }); + return order; } catch (Exception ex) { @@ -73,11 +75,16 @@ namespace ComputerShopRestApi.Controllers } [HttpPost] - public void CreateOrder(OrderBindingModel model) + public void CreateOrder(int assembly_id, int amount, OrderBindingModel model) { try { - _order.CreateOrder(model); + var new_order = _order.CreateOrder(model); + if (new_order != null) + { + _order.AddAssembly(new OrderSearchModel() { Id = new_order.Id }, + new AssemblySearchModel() { Id = assembly_id } , amount); + } } catch (Exception ex) { @@ -165,11 +172,11 @@ namespace ComputerShopRestApi.Controllers } [HttpPost] - public void AddComponent(Tuple model) + public void AddAssembly(Tuple model) { try { - _order.AddComponent(model.Item1, model.Item2, model.Item3); + _order.AddAssembly(model.Item1, model.Item2, model.Item3); } catch (Exception ex) { @@ -177,6 +184,7 @@ namespace ComputerShopRestApi.Controllers throw; } } + [HttpPost] public void EditOrder(OrderBindingModel model) @@ -192,11 +200,12 @@ namespace ComputerShopRestApi.Controllers } } [HttpGet] - public ComponentViewModel? GetComponentsByOrder(int orderId) + public List? GetAssembliesByOrder(int orderId) { try { - return _orderStorage.GetComponentsByOrder(new OrderSearchModel(){ Id = orderId }); + var list = _orderStorage.GetAssembliesByOrder(new OrderSearchModel() { Id = orderId }); + return list; } catch (Exception ex) { diff --git a/ComputerShopProvider/OrdererClientApp/Controllers/HomeController.cs b/ComputerShopProvider/OrdererClientApp/Controllers/HomeController.cs index 842600e..a315936 100644 --- a/ComputerShopProvider/OrdererClientApp/Controllers/HomeController.cs +++ b/ComputerShopProvider/OrdererClientApp/Controllers/HomeController.cs @@ -47,6 +47,7 @@ namespace OrdererClientApp.Controllers } return View(APIClient.GetRequest>($"api/order/getorderlist?clientId={APIClient.Client.Id}")); } + public IActionResult Supply() { if (APIClient.Client == null) @@ -183,11 +184,11 @@ namespace OrdererClientApp.Controllers [HttpGet] public IActionResult CreateOrder() { - ViewBag.Components = APIClient.GetRequest>($"api/component/getcomponentlist?clientId={APIClient.Client.Id}"); + ViewBag.Components = APIClient.GetRequest>($"api/assembly/getassemblylist?clientId={APIClient.Client.Id}"); return View(); } [HttpPost] - public void CreateOrder(int sum, int component_id, int amount) + public void CreateOrder(int sum, int assembly_id, int amount) { if (APIClient.Client == null) { @@ -199,17 +200,12 @@ namespace OrdererClientApp.Controllers Sum = sum }; - APIClient.PostRequest("api/order/createorder", order); - APIClient.PostRequest("api/order/addcomponent", Tuple.Create( - new OrderSearchModel() { Id = order.Id }, - new ComponentSearchModel() { Id = component_id }, - amount - )); + APIClient.PostRequest($"api/order/createorder?assembly_id={assembly_id}&amount={amount}", order); Response.Redirect("Order"); } - [HttpGet] + [HttpGet] public IActionResult DeleteOrder() { ViewBag.Orders = APIClient.GetRequest>($"api/main/getorderlist/?clientId={APIClient.Client.Id}"); @@ -273,22 +269,18 @@ namespace OrdererClientApp.Controllers { return Redirect("~/Home/Enter"); } - var orderViewModel = APIClient.GetRequest>($"api/order/getorder?id={id}"); - var componentViewModels = APIClient.GetRequest>($"api/order/getcomponentsbyorder?orderid={id}"); - ViewBag.Order = orderViewModel; - ViewBag.Components = componentViewModels; + var componentViewModels = APIClient.GetRequest?>($"api/order/GetAssembliesByOrder?orderid={id}"); + var assemblies = APIClient.GetRequest?>($"api/assembly/getassemblylist?clientId={APIClient.Client.Id}"); - var list = new List - { - orderViewModel, - componentViewModels - }; + ViewBag.Order = id; + ViewBag.Components = componentViewModels; + ViewBag.Assemblies = assemblies; - return View(list); + return View(); } [HttpPost] - public void EditOrder(int order, double cost, int component = -1, int amount = -1) + public void AddAssemblyToOrder(int order, double cost, int component, int amount) { if (APIClient.Client == null) { @@ -301,9 +293,9 @@ namespace OrdererClientApp.Controllers if (component >= 0 & amount > 1) { - APIClient.PostRequest("api/order/AddComponent", Tuple.Create( + APIClient.PostRequest("api/order/AddAssembly", Tuple.Create( new OrderSearchModel() { Id = order }, - new ComponentSearchModel() { Id = component }, + new AssemblySearchModel() { Id = component }, amount )); } @@ -339,8 +331,15 @@ namespace OrdererClientApp.Controllers [HttpPost] public double Calc(int count, int assembly) { - var or = APIClient.GetRequest($"api/main/getassembly?assemblyId={assembly}"); - return count * (or?.Sum ?? 1); + var ass = APIClient.GetRequest($"api/main/getassembly?assemblyId={assembly}"); + return count * (ass?.Price ?? 1); } - } + + [HttpPost] + public double CalcOrder(int count, int componentid) + { + var or = APIClient.GetRequest($"api/main/getassembly?assemblyId={componentid}"); + return count * (or?.Sum ?? 1); + } + } } \ No newline at end of file diff --git a/ComputerShopProvider/OrdererClientApp/Program.cs b/ComputerShopProvider/OrdererClientApp/Program.cs index 5bf31e7..9fcdcab 100644 --- a/ComputerShopProvider/OrdererClientApp/Program.cs +++ b/ComputerShopProvider/OrdererClientApp/Program.cs @@ -47,3 +47,4 @@ app.MapControllerRoute( pattern: "{controller=Home}/{action=Index}/{id?}"); app.Run(); + diff --git a/ComputerShopProvider/OrdererClientApp/Views/Home/CreateOrder.cshtml b/ComputerShopProvider/OrdererClientApp/Views/Home/CreateOrder.cshtml index 419d0b9..cc794bb 100644 --- a/ComputerShopProvider/OrdererClientApp/Views/Home/CreateOrder.cshtml +++ b/ComputerShopProvider/OrdererClientApp/Views/Home/CreateOrder.cshtml @@ -4,7 +4,7 @@ ViewData["Title"] = "CreateOrder"; } -@model Dictionary +@model Dictionary @@ -13,15 +13,19 @@
- +
- +
Количество:
+
+
Сумма:
+
+
@@ -29,25 +33,30 @@ \ No newline at end of file diff --git a/ComputerShopProvider/OrdererClientApp/Views/Home/EditOrder.cshtml b/ComputerShopProvider/OrdererClientApp/Views/Home/EditOrder.cshtml index 554058f..f0274bc 100644 --- a/ComputerShopProvider/OrdererClientApp/Views/Home/EditOrder.cshtml +++ b/ComputerShopProvider/OrdererClientApp/Views/Home/EditOrder.cshtml @@ -1,66 +1,98 @@ @using ComputerShopContracts.ViewModels; -@using ComputerShopDataModels.Models; @{ ViewData["Title"] = "OrderEditing"; } +
+

Сборки в заказе:

+
+ + + + + + + + + + @if (ViewBag.Components == null) + { +
+

NULL

+
+ } + @if (ViewBag.Components != null && ViewBag.Components.Count > 0) + { + @foreach (var item in ViewBag.Components) + { + + + + + } + } + else + { +
+

Нет данных

+
+ } + +
+ Название + + Цена +
@(item.AssemblyName)@(item.Price.ToString())
-@model IEnumerable - -
+
- +
- asp-items="@(new SelectList(@ViewBag.Order, "Id", "DateCreate")) +
- - Номер заказа: - - - @foreach (var order in ViewBag.Order) - { - - @order.Id - - } - -
-
Комплектующие в заказе:
-
- - @if (ViewBag.Components != null) - @foreach (var components in ViewBag.Components) - { - - @foreach (var component in components) - { - - if (component != null) - { - - @component.ComponentName - - } - } - - } - -
- -
- +
+
Количество:
+
-
+
+
+
+
-
Количество:
-
-
-
-
-
-
+ + +
+ + + \ No newline at end of file diff --git a/ComputerShopProvider/OrdererClientApp/Views/Home/Order.cshtml b/ComputerShopProvider/OrdererClientApp/Views/Home/Order.cshtml index 0ea2332..1c2855b 100644 --- a/ComputerShopProvider/OrdererClientApp/Views/Home/Order.cshtml +++ b/ComputerShopProvider/OrdererClientApp/Views/Home/Order.cshtml @@ -32,9 +32,6 @@ Номер - - Сумма - Статус @@ -44,6 +41,10 @@ Дата выполнения + + Сумма + + @@ -53,9 +54,6 @@ @Html.DisplayFor(modelItem => item.Id) - - @Html.DisplayFor(modelItem => item.Sum) - @Html.DisplayFor(modelItem => item.Status) @@ -66,6 +64,8 @@ @Html.DisplayFor(modelItem => item.DateImplement) + @Html.DisplayFor(modelItem => item.Sum) +
@@ -82,10 +82,10 @@ - - - -
+
+ + +
} diff --git a/ComputerShopProvider/OrdererClientApp/Views/Home/Receivings.cshtml b/ComputerShopProvider/OrdererClientApp/Views/Home/Receivings.cshtml index cd0adb9..63c70e6 100644 --- a/ComputerShopProvider/OrdererClientApp/Views/Home/Receivings.cshtml +++ b/ComputerShopProvider/OrdererClientApp/Views/Home/Receivings.cshtml @@ -62,12 +62,13 @@ +
- + }