From 8a7ccde75cccef99119b8780eecb71c91a8390f7 Mon Sep 17 00:00:00 2001 From: dex_moth Date: Thu, 30 May 2024 07:44:40 +0400 Subject: [PATCH] =?UTF-8?q?=D1=8A=D1=83=D1=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogic/OrderLogic.cs | 2 +- .../BindingModels/ComponentBindingModel.cs | 2 +- .../BindingModels/OrderBindingModel.cs | 6 +- .../BindingModels/ReportBindingModel.cs | 2 + .../ViewModels/ComponentViewModel.cs | 2 +- .../ComponentSelectionViewModel.cs | 9 - .../ViewModels/OrderViewModel.cs | 9 +- .../ViewModels/ReportComponentsViewModel.cs | 11 + .../Models/IComponentModel.cs | 2 +- .../Models/IOrderModel.cs | 4 +- .../ComputerHardwareStoreDBContext.cs | 3 +- .../Implements/OrderStorage.cs | 44 +- .../Models/Component.cs | 6 +- .../Models/Order.cs | 106 +-- .../Models/OrderProduct.cs | 17 - .../Views/Home/Enter.cshtml | 32 + .../Views/Home/Index.cshtml | 32 + .../Views/Home/Privacy.cshtml | 29 + .../Views/Home/Register.cshtml | 36 + .../Views/StoreKeeper/Components.cshtml | 127 +++ .../Views/StoreKeeper/CreateComponent.cshtml | 22 + .../Views/StoreKeeper/CreateOrder.cshtml | 57 ++ .../Views/StoreKeeper/CreateProduct.cshtml | 152 ++++ .../Views/StoreKeeper/LinkBuilds.cshtml | 183 ++++ .../Views/StoreKeeper/ListBuilds.cshtml | 152 ++++ .../Views/StoreKeeper/MainStorekeeper.cshtml | 8 + .../Views/StoreKeeper/Orders.cshtml | 168 ++++ .../Views/StoreKeeper/Products.cshtml | 72 ++ .../Views/StoreKeeper/Report.cshtml | 94 ++ .../Views/StoreKeeper/UpdateProduct.cshtml | 181 ++++ .../Views/StoreKeepers/Create.cshtml | 43 - .../Views/StoreKeepers/Delete.cshtml | 39 - .../Views/StoreKeepers/Details.cshtml | 36 - .../Views/StoreKeepers/Edit.cshtml | 44 - .../Views/StoreKeepers/Index.cshtml | 47 - .../StoreKeeperClient/APIClient.cs | 2 +- .../Controllers/HomeController.cs | 365 ++------ .../Controllers/StoreKeeperController.cs | 813 ++++++++++-------- .../StoreKeeperClient/LoginedStoreKeeper.cs | 9 + .../StoreKeeperClient.csproj | 19 +- .../Views/Home/BuildByProductsReport.cshtml | 53 -- .../Views/Home/ComponentToBuild.cshtml | 29 - .../Views/Home/Components.cshtml | 58 -- ...omponentsByPurchasesAndOrdersReport.cshtml | 58 -- .../Views/Home/CreateComponent.cshtml | 25 - .../Views/Home/CreateOrder.cshtml | 29 - .../Views/Home/CreateProduct.cshtml | 129 --- .../Views/Home/DeleteComponent.cshtml | 17 - .../Views/Home/DeleteOrder.cshtml | 17 - .../Views/Home/DeleteProduct.cshtml | 17 - .../StoreKeeperClient/Views/Home/Enter.cshtml | 42 +- .../StoreKeeperClient/Views/Home/Index.cshtml | 43 +- .../StoreKeeperClient/Views/Home/Mails.cshtml | 48 -- .../Views/Home/Orders.cshtml | 57 -- .../Views/Home/Privacy.cshtml | 29 + .../Views/Home/Products.cshtml | 59 -- .../Views/Home/Purchases.cshtml | 57 -- .../Views/Home/Register.cshtml | 49 +- .../Views/Home/ReportOnSite.cshtml | 5 - .../Views/Home/UpdateComponent.cshtml | 52 -- .../Views/Home/UpdateOrder.cshtml | 46 - .../Views/Home/UpdateProduct.cshtml | 69 -- .../Views/Shared/_Layout.cshtml | 8 +- .../Views/Storekeeper/Components.cshtml | 125 +++ .../Views/Storekeeper/CreateComponent.cshtml | 22 + .../Views/Storekeeper/CreateOrder.cshtml | 57 ++ .../Views/Storekeeper/CreateProduct.cshtml | 152 ++++ .../Views/Storekeeper/LinkBuilds.cshtml | 183 ++++ .../Views/Storekeeper/ListBuilds.cshtml | 152 ++++ .../Views/Storekeeper/MainStorekeeper.cshtml | 8 + .../Views/Storekeeper/Orders.cshtml | 168 ++++ .../Views/Storekeeper/Products.cshtml | 72 ++ .../Views/Storekeeper/Report.cshtml | 94 ++ .../Views/Storekeeper/UpdateProduct.cshtml | 181 ++++ .../dist/additional-methods.js | 2 +- .../wwwroot/lib/jquery/dist/jquery.js | 2 +- 76 files changed, 3321 insertions(+), 1880 deletions(-) delete mode 100644 ComputerHardwareStore/ComputerHardwareStoreContracts/ViewModels/HelperModels/ComponentSelectionViewModel.cs create mode 100644 ComputerHardwareStore/ComputerHardwareStoreContracts/ViewModels/ReportComponentsViewModel.cs delete mode 100644 ComputerHardwareStore/ComputerHardwareStoreDatabaseImplement/Models/OrderProduct.cs create mode 100644 ComputerHardwareStore/ComputerHardwareStoreREST/Views/Home/Enter.cshtml create mode 100644 ComputerHardwareStore/ComputerHardwareStoreREST/Views/Home/Index.cshtml create mode 100644 ComputerHardwareStore/ComputerHardwareStoreREST/Views/Home/Privacy.cshtml create mode 100644 ComputerHardwareStore/ComputerHardwareStoreREST/Views/Home/Register.cshtml create mode 100644 ComputerHardwareStore/ComputerHardwareStoreREST/Views/StoreKeeper/Components.cshtml create mode 100644 ComputerHardwareStore/ComputerHardwareStoreREST/Views/StoreKeeper/CreateComponent.cshtml create mode 100644 ComputerHardwareStore/ComputerHardwareStoreREST/Views/StoreKeeper/CreateOrder.cshtml create mode 100644 ComputerHardwareStore/ComputerHardwareStoreREST/Views/StoreKeeper/CreateProduct.cshtml create mode 100644 ComputerHardwareStore/ComputerHardwareStoreREST/Views/StoreKeeper/LinkBuilds.cshtml create mode 100644 ComputerHardwareStore/ComputerHardwareStoreREST/Views/StoreKeeper/ListBuilds.cshtml create mode 100644 ComputerHardwareStore/ComputerHardwareStoreREST/Views/StoreKeeper/MainStorekeeper.cshtml create mode 100644 ComputerHardwareStore/ComputerHardwareStoreREST/Views/StoreKeeper/Orders.cshtml create mode 100644 ComputerHardwareStore/ComputerHardwareStoreREST/Views/StoreKeeper/Products.cshtml create mode 100644 ComputerHardwareStore/ComputerHardwareStoreREST/Views/StoreKeeper/Report.cshtml create mode 100644 ComputerHardwareStore/ComputerHardwareStoreREST/Views/StoreKeeper/UpdateProduct.cshtml delete mode 100644 ComputerHardwareStore/ComputerHardwareStoreREST/Views/StoreKeepers/Create.cshtml delete mode 100644 ComputerHardwareStore/ComputerHardwareStoreREST/Views/StoreKeepers/Delete.cshtml delete mode 100644 ComputerHardwareStore/ComputerHardwareStoreREST/Views/StoreKeepers/Details.cshtml delete mode 100644 ComputerHardwareStore/ComputerHardwareStoreREST/Views/StoreKeepers/Edit.cshtml delete mode 100644 ComputerHardwareStore/ComputerHardwareStoreREST/Views/StoreKeepers/Index.cshtml create mode 100644 ComputerHardwareStore/StoreKeeperClient/LoginedStoreKeeper.cs delete mode 100644 ComputerHardwareStore/StoreKeeperClient/Views/Home/BuildByProductsReport.cshtml delete mode 100644 ComputerHardwareStore/StoreKeeperClient/Views/Home/ComponentToBuild.cshtml delete mode 100644 ComputerHardwareStore/StoreKeeperClient/Views/Home/Components.cshtml delete mode 100644 ComputerHardwareStore/StoreKeeperClient/Views/Home/ComponentsByPurchasesAndOrdersReport.cshtml delete mode 100644 ComputerHardwareStore/StoreKeeperClient/Views/Home/CreateComponent.cshtml delete mode 100644 ComputerHardwareStore/StoreKeeperClient/Views/Home/CreateOrder.cshtml delete mode 100644 ComputerHardwareStore/StoreKeeperClient/Views/Home/CreateProduct.cshtml delete mode 100644 ComputerHardwareStore/StoreKeeperClient/Views/Home/DeleteComponent.cshtml delete mode 100644 ComputerHardwareStore/StoreKeeperClient/Views/Home/DeleteOrder.cshtml delete mode 100644 ComputerHardwareStore/StoreKeeperClient/Views/Home/DeleteProduct.cshtml delete mode 100644 ComputerHardwareStore/StoreKeeperClient/Views/Home/Mails.cshtml delete mode 100644 ComputerHardwareStore/StoreKeeperClient/Views/Home/Orders.cshtml create mode 100644 ComputerHardwareStore/StoreKeeperClient/Views/Home/Privacy.cshtml delete mode 100644 ComputerHardwareStore/StoreKeeperClient/Views/Home/Products.cshtml delete mode 100644 ComputerHardwareStore/StoreKeeperClient/Views/Home/Purchases.cshtml delete mode 100644 ComputerHardwareStore/StoreKeeperClient/Views/Home/ReportOnSite.cshtml delete mode 100644 ComputerHardwareStore/StoreKeeperClient/Views/Home/UpdateComponent.cshtml delete mode 100644 ComputerHardwareStore/StoreKeeperClient/Views/Home/UpdateOrder.cshtml delete mode 100644 ComputerHardwareStore/StoreKeeperClient/Views/Home/UpdateProduct.cshtml create mode 100644 ComputerHardwareStore/StoreKeeperClient/Views/Storekeeper/Components.cshtml create mode 100644 ComputerHardwareStore/StoreKeeperClient/Views/Storekeeper/CreateComponent.cshtml create mode 100644 ComputerHardwareStore/StoreKeeperClient/Views/Storekeeper/CreateOrder.cshtml create mode 100644 ComputerHardwareStore/StoreKeeperClient/Views/Storekeeper/CreateProduct.cshtml create mode 100644 ComputerHardwareStore/StoreKeeperClient/Views/Storekeeper/LinkBuilds.cshtml create mode 100644 ComputerHardwareStore/StoreKeeperClient/Views/Storekeeper/ListBuilds.cshtml create mode 100644 ComputerHardwareStore/StoreKeeperClient/Views/Storekeeper/MainStorekeeper.cshtml create mode 100644 ComputerHardwareStore/StoreKeeperClient/Views/Storekeeper/Orders.cshtml create mode 100644 ComputerHardwareStore/StoreKeeperClient/Views/Storekeeper/Products.cshtml create mode 100644 ComputerHardwareStore/StoreKeeperClient/Views/Storekeeper/Report.cshtml create mode 100644 ComputerHardwareStore/StoreKeeperClient/Views/Storekeeper/UpdateProduct.cshtml diff --git a/ComputerHardwareStore/ComputerHardwareStoreBusinessLogic/BusinessLogic/OrderLogic.cs b/ComputerHardwareStore/ComputerHardwareStoreBusinessLogic/BusinessLogic/OrderLogic.cs index 7059846..8a9f26f 100644 --- a/ComputerHardwareStore/ComputerHardwareStoreBusinessLogic/BusinessLogic/OrderLogic.cs +++ b/ComputerHardwareStore/ComputerHardwareStoreBusinessLogic/BusinessLogic/OrderLogic.cs @@ -76,7 +76,7 @@ namespace ComputerHardwareStoreBusinessLogic.BusinessLogic throw new ArgumentNullException(nameof(element)); } - model.OrderProducts = element.OrderProducts; + model.ProductId = element.ProductId; model.DateCreate = element.DateCreate; model.Status = element.Status; diff --git a/ComputerHardwareStore/ComputerHardwareStoreContracts/BindingModels/ComponentBindingModel.cs b/ComputerHardwareStore/ComputerHardwareStoreContracts/BindingModels/ComponentBindingModel.cs index e14244d..af0759b 100644 --- a/ComputerHardwareStore/ComputerHardwareStoreContracts/BindingModels/ComponentBindingModel.cs +++ b/ComputerHardwareStore/ComputerHardwareStoreContracts/BindingModels/ComponentBindingModel.cs @@ -7,6 +7,6 @@ namespace ComputerHardwareStoreContracts.BindingModels public int Id { get; set; } public string Name { get; set; } = string.Empty; public double Cost { get; set; } - public IStoreKeeperModel StoreKeeper { get; set; } + public int StoreKeeperId { get; set; } } } diff --git a/ComputerHardwareStore/ComputerHardwareStoreContracts/BindingModels/OrderBindingModel.cs b/ComputerHardwareStore/ComputerHardwareStoreContracts/BindingModels/OrderBindingModel.cs index e1017a0..0acaac9 100644 --- a/ComputerHardwareStore/ComputerHardwareStoreContracts/BindingModels/OrderBindingModel.cs +++ b/ComputerHardwareStore/ComputerHardwareStoreContracts/BindingModels/OrderBindingModel.cs @@ -10,6 +10,8 @@ namespace ComputerHardwareStoreContracts.BindingModels public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; public DateTime DateCreate { get; set; } = DateTime.Now; public DateTime? DateImplement { get; set; } = null; - public Dictionary OrderProducts { get; set; } = new(); - } + //public Dictionary OrderProducts { get; set; } = new(); + public int ProductId { get; set; } + public int Count { get; set; } + } } diff --git a/ComputerHardwareStore/ComputerHardwareStoreContracts/BindingModels/ReportBindingModel.cs b/ComputerHardwareStore/ComputerHardwareStoreContracts/BindingModels/ReportBindingModel.cs index b0d98e3..f8836bc 100644 --- a/ComputerHardwareStore/ComputerHardwareStoreContracts/BindingModels/ReportBindingModel.cs +++ b/ComputerHardwareStore/ComputerHardwareStoreContracts/BindingModels/ReportBindingModel.cs @@ -5,5 +5,7 @@ public string FileName { get; set; } = string.Empty; public DateTime? DateFrom { get; set; } public DateTime? DateTo { get; set; } + public int UserId { get; set; } + public string UserEmail { get; set; } = string.Empty; } } diff --git a/ComputerHardwareStore/ComputerHardwareStoreContracts/ViewModels/ComponentViewModel.cs b/ComputerHardwareStore/ComputerHardwareStoreContracts/ViewModels/ComponentViewModel.cs index eb9fd9a..6aadb04 100644 --- a/ComputerHardwareStore/ComputerHardwareStoreContracts/ViewModels/ComponentViewModel.cs +++ b/ComputerHardwareStore/ComputerHardwareStoreContracts/ViewModels/ComponentViewModel.cs @@ -10,6 +10,6 @@ namespace ComputerHardwareStoreContracts.ViewModels public string Name { get; set; } = string.Empty; [DisplayName("Цена")] public double Cost { get; set; } - public IStoreKeeperModel StoreKeeper { get; set; } + public int StoreKeeperId { get; set; } } } diff --git a/ComputerHardwareStore/ComputerHardwareStoreContracts/ViewModels/HelperModels/ComponentSelectionViewModel.cs b/ComputerHardwareStore/ComputerHardwareStoreContracts/ViewModels/HelperModels/ComponentSelectionViewModel.cs deleted file mode 100644 index 0867d02..0000000 --- a/ComputerHardwareStore/ComputerHardwareStoreContracts/ViewModels/HelperModels/ComponentSelectionViewModel.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace ComputerHardwareStoreContracts.ViewModels.HelperModels -{ - public class ComponentSelectionViewModel - { - public int Id { get; set; } - public bool IsSelected { get; set; } - public int Quantity { get; set; } - } -} diff --git a/ComputerHardwareStore/ComputerHardwareStoreContracts/ViewModels/OrderViewModel.cs b/ComputerHardwareStore/ComputerHardwareStoreContracts/ViewModels/OrderViewModel.cs index a0b6602..3811c20 100644 --- a/ComputerHardwareStore/ComputerHardwareStoreContracts/ViewModels/OrderViewModel.cs +++ b/ComputerHardwareStore/ComputerHardwareStoreContracts/ViewModels/OrderViewModel.cs @@ -8,7 +8,12 @@ namespace ComputerHardwareStoreContracts.ViewModels { [DisplayName("Номер")] public int Id { get; set; } - [DisplayName("Сумма")] + public int ProductId { get; set; } + [DisplayName("Товар")] + public string ProductName { get; set; } = string.Empty; + [DisplayName("Количество")] + public int Count { get; set; } + [DisplayName("Сумма")] public double Sum { get; set; } [DisplayName("Статус")] public OrderStatus Status { get; set; } @@ -16,6 +21,6 @@ namespace ComputerHardwareStoreContracts.ViewModels public DateTime DateCreate { get; set; } [DisplayName("Дата выполнения")] public DateTime? DateImplement { get; set; } - public Dictionary OrderProducts { get; set; } = new(); + // public Dictionary OrderProducts { get; set; } = new(); } } diff --git a/ComputerHardwareStore/ComputerHardwareStoreContracts/ViewModels/ReportComponentsViewModel.cs b/ComputerHardwareStore/ComputerHardwareStoreContracts/ViewModels/ReportComponentsViewModel.cs new file mode 100644 index 0000000..2e0d0f7 --- /dev/null +++ b/ComputerHardwareStore/ComputerHardwareStoreContracts/ViewModels/ReportComponentsViewModel.cs @@ -0,0 +1,11 @@ +namespace HardwareShopContracts.ViewModels +{ + public class ReportComponentsViewModel + { + public string ComponentName { get; set; } = string.Empty; + + public int TotalCount { get; set; } + + public List> ProductOrBuilds { get; set; } = new(); + } +} diff --git a/ComputerHardwareStore/ComputerHardwareStoreDataModels/Models/IComponentModel.cs b/ComputerHardwareStore/ComputerHardwareStoreDataModels/Models/IComponentModel.cs index 84f259d..6eea153 100644 --- a/ComputerHardwareStore/ComputerHardwareStoreDataModels/Models/IComponentModel.cs +++ b/ComputerHardwareStore/ComputerHardwareStoreDataModels/Models/IComponentModel.cs @@ -4,6 +4,6 @@ { string Name { get; } double Cost { get; } - IStoreKeeperModel StoreKeeper { get; } + int StoreKeeperId { get; } } } diff --git a/ComputerHardwareStore/ComputerHardwareStoreDataModels/Models/IOrderModel.cs b/ComputerHardwareStore/ComputerHardwareStoreDataModels/Models/IOrderModel.cs index 3e7f94e..828a535 100644 --- a/ComputerHardwareStore/ComputerHardwareStoreDataModels/Models/IOrderModel.cs +++ b/ComputerHardwareStore/ComputerHardwareStoreDataModels/Models/IOrderModel.cs @@ -8,6 +8,8 @@ namespace ComputerHardwareStoreDataModels.Models OrderStatus Status { get; } DateTime DateCreate { get; } DateTime? DateImplement { get; } - public Dictionary OrderProducts { get; } + int ProductId { get; } + int Count { get; } + //public Dictionary OrderProducts { get; } } } diff --git a/ComputerHardwareStore/ComputerHardwareStoreDatabaseImplement/ComputerHardwareStoreDBContext.cs b/ComputerHardwareStore/ComputerHardwareStoreDatabaseImplement/ComputerHardwareStoreDBContext.cs index c790b6d..2965dfd 100644 --- a/ComputerHardwareStore/ComputerHardwareStoreDatabaseImplement/ComputerHardwareStoreDBContext.cs +++ b/ComputerHardwareStore/ComputerHardwareStoreDatabaseImplement/ComputerHardwareStoreDBContext.cs @@ -8,7 +8,7 @@ namespace ComputerHardwareStoreDatabaseImplement protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { //optionsBuilder.UseNpgsql("Host=192.168.1.61:5432;Database=computerhardwarestore;Username=compstore;Password=compstore"); - optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=ComputerHardwareStore;Username=postgres;Password=postgres"); + optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=ComputerHardwareStore2;Username=postgres;Password=postgres"); AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); } public virtual DbSet Components { set; get; } @@ -18,7 +18,6 @@ namespace ComputerHardwareStoreDatabaseImplement public virtual DbSet StoreKeepers { set; get; } public virtual DbSet Builds { set; get; } public virtual DbSet Orders { set; get; } - public virtual DbSet OrderProducts { set; get; } public virtual DbSet BuildComponents { set; get; } public virtual DbSet Comments { set; get; } public virtual DbSet Vendors { set; get; } diff --git a/ComputerHardwareStore/ComputerHardwareStoreDatabaseImplement/Implements/OrderStorage.cs b/ComputerHardwareStore/ComputerHardwareStoreDatabaseImplement/Implements/OrderStorage.cs index 2378d44..32dcd2a 100644 --- a/ComputerHardwareStore/ComputerHardwareStoreDatabaseImplement/Implements/OrderStorage.cs +++ b/ComputerHardwareStore/ComputerHardwareStoreDatabaseImplement/Implements/OrderStorage.cs @@ -13,8 +13,7 @@ namespace ComputerHardwareStoreDatabaseImplement.Implements { using var context = new ComputerHardwareStoreDBContext(); return context.Orders - .Include(o => o.Products) - .ThenInclude(o => o.Product) + .Include(o => o.Product) .Select(o => o.GetViewModel) .ToList(); } @@ -23,8 +22,7 @@ namespace ComputerHardwareStoreDatabaseImplement.Implements { using var context = new ComputerHardwareStoreDBContext(); return context.Orders - .Include(o => o.Products) - .ThenInclude(o => o.Product) + .Include(o => o.Product) .Where(o => (model.Id.HasValue && o.Id == model.Id) || ((model.DateFrom.HasValue && model.DateTo.HasValue) && @@ -43,35 +41,36 @@ namespace ComputerHardwareStoreDatabaseImplement.Implements } using var context = new ComputerHardwareStoreDBContext(); return context.Orders - .Include(o => o.Products) - .ThenInclude(o => o.Product) + .Include(o => o.Product) .FirstOrDefault(o => o.Id == model.Id)? .GetViewModel; } - public OrderViewModel? Insert(OrderBindingModel model) - { - using var context = new ComputerHardwareStoreDBContext(); - var newOrder = Order.Create(context, model); - if (newOrder == null) - { - return null; - } - context.Orders.Add(newOrder); - context.SaveChanges(); - return newOrder.GetViewModel; - } + public OrderViewModel? Insert(OrderBindingModel model) + { + var newOrder = Order.Create(model); + if (newOrder == null) + { + return null; + } + using var context = new ComputerHardwareStoreDBContext(); + context.Orders.Add(newOrder); + context.SaveChanges(); + return context.Orders + .Include(x => x.Product) + .FirstOrDefault(x => x.Id == newOrder.Id) + ?.GetViewModel; + } - public OrderViewModel? Update(OrderBindingModel model) + public OrderViewModel? Update(OrderBindingModel model) { using var context = new ComputerHardwareStoreDBContext(); using var transaction = context.Database.BeginTransaction(); try { var order = context.Orders - .Include(o => o.Products) - .ThenInclude(o => o.Product) + .Include(o => o.Product) .FirstOrDefault(o => o.Id == model.Id); if (order == null) { @@ -93,8 +92,7 @@ namespace ComputerHardwareStoreDatabaseImplement.Implements { using var context = new ComputerHardwareStoreDBContext(); var element = context.Orders - .Include(o => o.Products) - .ThenInclude(o => o.Product) + .Include(o => o.Product) .FirstOrDefault(o => o.Id == model.Id); if (element != null) { diff --git a/ComputerHardwareStore/ComputerHardwareStoreDatabaseImplement/Models/Component.cs b/ComputerHardwareStore/ComputerHardwareStoreDatabaseImplement/Models/Component.cs index 80f2389..0a35b4c 100644 --- a/ComputerHardwareStore/ComputerHardwareStoreDatabaseImplement/Models/Component.cs +++ b/ComputerHardwareStore/ComputerHardwareStoreDatabaseImplement/Models/Component.cs @@ -14,9 +14,9 @@ namespace ComputerHardwareStoreDatabaseImplement.Models [Required] public double Cost { get; set; } [Required] - public virtual StoreKeeper? StoreKeeperЗЛ { get; set; } + public virtual StoreKeeper? StoreKeeper { get; set; } [NotMapped] - public IStoreKeeperModel? StoreKeeper { get; set; } + public int StoreKeeperId { get; set; } [ForeignKey("ComponentId")] public virtual List ProductComponents { get; set; } = new(); @@ -33,7 +33,7 @@ namespace ComputerHardwareStoreDatabaseImplement.Models Id = model.Id, Name = model.Name, Cost = model.Cost, - StoreKeeper = model.StoreKeeper + StoreKeeperId = model.StoreKeeperId }; } public void Update (ComponentBindingModel model) diff --git a/ComputerHardwareStore/ComputerHardwareStoreDatabaseImplement/Models/Order.cs b/ComputerHardwareStore/ComputerHardwareStoreDatabaseImplement/Models/Order.cs index bf50b41..efe440f 100644 --- a/ComputerHardwareStore/ComputerHardwareStoreDatabaseImplement/Models/Order.cs +++ b/ComputerHardwareStore/ComputerHardwareStoreDatabaseImplement/Models/Order.cs @@ -10,7 +10,10 @@ namespace ComputerHardwareStoreDatabaseImplement.Models public class Order : IOrderModel { public int Id { get; private set; } - [Required] + [Required] + public int ProductId { get; set; } + public virtual Product Product { get; set; } = null!; + [Required] public int Count { get; set; } [Required] public double Sum { get; set; } @@ -20,65 +23,44 @@ namespace ComputerHardwareStoreDatabaseImplement.Models public DateTime DateCreate { get; set; } = DateTime.Now; public DateTime? DateImplement { get; set; } - private Dictionary? _orderProducts = null; - [NotMapped] - public Dictionary OrderProducts - { - get - { - if (_orderProducts == null) - { - _orderProducts = Products - .ToDictionary( - op => op.ProductId, - op => (op.Product as IProductModel, op.Count)); - } - return _orderProducts; - } - } - [ForeignKey("OrderId")] - public virtual List Products { get; set; } = new(); - public static Order? Create(ComputerHardwareStoreDBContext context, OrderBindingModel model) - { - if (model == null) - { - return null; - } - return new Order() - { - Id = model.Id, - Sum = model.Sum, - Status = model.Status, - DateCreate = model.DateCreate, - DateImplement = model.DateImplement, - Products = context.Products - .Where(p => model.OrderProducts.ContainsKey(p.Id)) - .Select(p => new OrderProduct() - { - OrderId = model.Id, - ProductId = p.Id, - Product = p, - Count = model.OrderProducts[p.Id].Item2 - }) - .ToList() - }; - } - public void Update(OrderBindingModel model) - { - if (model == null) - { - return; - } - Status = model.Status; - DateImplement = model.DateImplement; - } - public OrderViewModel GetViewModel => new() - { - Id = Id, - Sum = Sum, - Status = Status, - DateCreate = DateCreate, - DateImplement = DateImplement, - }; - } + public static Order? Create(OrderBindingModel? model) + { + if (model == null) + { + return null; + } + return new Order() + { + Id = model.Id, + ProductId = model.ProductId, + Count = model.Count, + Sum = model.Sum, + Status = model.Status, + DateCreate = model.DateCreate, + DateImplement = model.DateImplement, + }; + } + + public void Update(OrderBindingModel? model) + { + if (model == null) + { + return; + } + Status = model.Status; + DateImplement = model.DateImplement; + } + + public OrderViewModel GetViewModel => new() + { + Id = Id, + ProductId = ProductId, + Count = Count, + Sum = Sum, + Status = Status, + DateCreate = DateCreate, + DateImplement = DateImplement, + ProductName = Product.Name + }; + } } \ No newline at end of file diff --git a/ComputerHardwareStore/ComputerHardwareStoreDatabaseImplement/Models/OrderProduct.cs b/ComputerHardwareStore/ComputerHardwareStoreDatabaseImplement/Models/OrderProduct.cs deleted file mode 100644 index 9930fe7..0000000 --- a/ComputerHardwareStore/ComputerHardwareStoreDatabaseImplement/Models/OrderProduct.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace ComputerHardwareStoreDatabaseImplement.Models -{ - public class OrderProduct - { - public int Id { get; set; } - [Required] - public int OrderId { get; set; } - [Required] - public int ProductId { get; set; } - [Required] - public int Count { get; set; } - public virtual Product Product { get; set; } = new(); - public virtual Order Order { get; set; } = new(); - } -} diff --git a/ComputerHardwareStore/ComputerHardwareStoreREST/Views/Home/Enter.cshtml b/ComputerHardwareStore/ComputerHardwareStoreREST/Views/Home/Enter.cshtml new file mode 100644 index 0000000..4640290 --- /dev/null +++ b/ComputerHardwareStore/ComputerHardwareStoreREST/Views/Home/Enter.cshtml @@ -0,0 +1,32 @@ +@{ + ViewData["Title"] = "Enter"; +} +@section Header { +
+ +
+} +
+

Вход

+
+
+
+ + +
+
+ + +
+
+ +
Регистрация +
+ diff --git a/ComputerHardwareStore/ComputerHardwareStoreREST/Views/Home/Index.cshtml b/ComputerHardwareStore/ComputerHardwareStoreREST/Views/Home/Index.cshtml new file mode 100644 index 0000000..654ebe1 --- /dev/null +++ b/ComputerHardwareStore/ComputerHardwareStoreREST/Views/Home/Index.cshtml @@ -0,0 +1,32 @@ +@{ + ViewData["Title"] = "Enter"; +} +@section Header { +
+ +
+} +
+ Добро пожаловать +
\ No newline at end of file diff --git a/ComputerHardwareStore/ComputerHardwareStoreREST/Views/Home/Privacy.cshtml b/ComputerHardwareStore/ComputerHardwareStoreREST/Views/Home/Privacy.cshtml new file mode 100644 index 0000000..cccbafd --- /dev/null +++ b/ComputerHardwareStore/ComputerHardwareStoreREST/Views/Home/Privacy.cshtml @@ -0,0 +1,29 @@ +@using ComputerHardwareStoreContracts.ViewModels + + +@model StoreKeeperViewModel + +@{ + ViewData["Title"] = "Privacy Policy"; + Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml"; +} +
+

Личные данные

+
+
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
\ No newline at end of file diff --git a/ComputerHardwareStore/ComputerHardwareStoreREST/Views/Home/Register.cshtml b/ComputerHardwareStore/ComputerHardwareStoreREST/Views/Home/Register.cshtml new file mode 100644 index 0000000..cca8ba6 --- /dev/null +++ b/ComputerHardwareStore/ComputerHardwareStoreREST/Views/Home/Register.cshtml @@ -0,0 +1,36 @@ +@{ + ViewData["Title"] = "Register"; +} +@section Header { +
+ +
+} +
+

Регистрация

+
+
+
+ + +
+
+ + +
+
+ + +
+ + Вернуться на вход + +
+ diff --git a/ComputerHardwareStore/ComputerHardwareStoreREST/Views/StoreKeeper/Components.cshtml b/ComputerHardwareStore/ComputerHardwareStoreREST/Views/StoreKeeper/Components.cshtml new file mode 100644 index 0000000..063faf6 --- /dev/null +++ b/ComputerHardwareStore/ComputerHardwareStoreREST/Views/StoreKeeper/Components.cshtml @@ -0,0 +1,127 @@ +@using ComputerHardwareStoreContracts.ViewModels + +@model List + +@{ + ViewData["Title"] = "Комплектующие"; + Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml"; +} + +
+

Комплектующие

+
+ + +
+ @{ +

+ Создать комплектующее +

+ + + + + + + + + + + @foreach (var item in Model) + { + + + + + + + } + +
+ Название + + Цена + + Дата приобретения + + Действия +
+ @Html.DisplayFor(modelItem => item.Name) + + @Html.DisplayFor(modelItem => item.Cost) + + @Html.DisplayFor(modelItem => item.Cost) + +
+ + Привязать + + + +
+
+ } +
+ +
+ +
+ +@section Scripts +{ + +} \ No newline at end of file diff --git a/ComputerHardwareStore/ComputerHardwareStoreREST/Views/StoreKeeper/CreateComponent.cshtml b/ComputerHardwareStore/ComputerHardwareStoreREST/Views/StoreKeeper/CreateComponent.cshtml new file mode 100644 index 0000000..cf54eb2 --- /dev/null +++ b/ComputerHardwareStore/ComputerHardwareStoreREST/Views/StoreKeeper/CreateComponent.cshtml @@ -0,0 +1,22 @@ +@{ + ViewData["Title"] = "Создание комплектующего"; + Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml"; +} + +
+

Создание комплектующего

+
+ +
+
+ + +
+
+ + +
+
+ +
+
diff --git a/ComputerHardwareStore/ComputerHardwareStoreREST/Views/StoreKeeper/CreateOrder.cshtml b/ComputerHardwareStore/ComputerHardwareStoreREST/Views/StoreKeeper/CreateOrder.cshtml new file mode 100644 index 0000000..d4a35c1 --- /dev/null +++ b/ComputerHardwareStore/ComputerHardwareStoreREST/Views/StoreKeeper/CreateOrder.cshtml @@ -0,0 +1,57 @@ +@{ + ViewData["Title"] = "Создание заказа"; + Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml"; +} + +
+

Создание заказа

+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ +@section Scripts + { + +} diff --git a/ComputerHardwareStore/ComputerHardwareStoreREST/Views/StoreKeeper/CreateProduct.cshtml b/ComputerHardwareStore/ComputerHardwareStoreREST/Views/StoreKeeper/CreateProduct.cshtml new file mode 100644 index 0000000..22b2bb9 --- /dev/null +++ b/ComputerHardwareStore/ComputerHardwareStoreREST/Views/StoreKeeper/CreateProduct.cshtml @@ -0,0 +1,152 @@ +@using HardwareShopContracts.ViewModels +@{ + ViewData["Title"] = "Создание товара"; + Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml"; +} + +
+

Создание товара

+
+ +
+
+ + +
+
+ + +
+

Комплектующие

+
+ +
+ + + + + + + + + + + + +
КомплектующееСтоимостьКоличествоСуммаДействие
+
+ +
+
+ + + +@section Scripts +{ + +} \ No newline at end of file diff --git a/ComputerHardwareStore/ComputerHardwareStoreREST/Views/StoreKeeper/LinkBuilds.cshtml b/ComputerHardwareStore/ComputerHardwareStoreREST/Views/StoreKeeper/LinkBuilds.cshtml new file mode 100644 index 0000000..95e60d1 --- /dev/null +++ b/ComputerHardwareStore/ComputerHardwareStoreREST/Views/StoreKeeper/LinkBuilds.cshtml @@ -0,0 +1,183 @@ +@using HardwareShopContracts.ViewModels +@{ + ViewData["Title"] = "Привязка сборок"; + Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml"; +} + +
+

Привязка сборок

+
+ +
+
+
+ +
+
+

Привязанные сборки

+ + + + + + + + + + +
СборкаКоличествоДействие
+
+ +
+
+ + + + +@section Scripts +{ + +} \ No newline at end of file diff --git a/ComputerHardwareStore/StoreKeeperClient/Views/Storekeeper/CreateComponent.cshtml b/ComputerHardwareStore/StoreKeeperClient/Views/Storekeeper/CreateComponent.cshtml new file mode 100644 index 0000000..cf54eb2 --- /dev/null +++ b/ComputerHardwareStore/StoreKeeperClient/Views/Storekeeper/CreateComponent.cshtml @@ -0,0 +1,22 @@ +@{ + ViewData["Title"] = "Создание комплектующего"; + Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml"; +} + +
+

Создание комплектующего

+
+ +
+
+ + +
+
+ + +
+
+ +
+
diff --git a/ComputerHardwareStore/StoreKeeperClient/Views/Storekeeper/CreateOrder.cshtml b/ComputerHardwareStore/StoreKeeperClient/Views/Storekeeper/CreateOrder.cshtml new file mode 100644 index 0000000..a3ebb16 --- /dev/null +++ b/ComputerHardwareStore/StoreKeeperClient/Views/Storekeeper/CreateOrder.cshtml @@ -0,0 +1,57 @@ +@{ + ViewData["Title"] = "Создание заказа"; + Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml"; +} + +
+

Создание заказа

+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ +@section Scripts + { + +} diff --git a/ComputerHardwareStore/StoreKeeperClient/Views/Storekeeper/CreateProduct.cshtml b/ComputerHardwareStore/StoreKeeperClient/Views/Storekeeper/CreateProduct.cshtml new file mode 100644 index 0000000..22b2bb9 --- /dev/null +++ b/ComputerHardwareStore/StoreKeeperClient/Views/Storekeeper/CreateProduct.cshtml @@ -0,0 +1,152 @@ +@using HardwareShopContracts.ViewModels +@{ + ViewData["Title"] = "Создание товара"; + Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml"; +} + +
+

Создание товара

+
+ +
+
+ + +
+
+ + +
+

Комплектующие

+
+ +
+ + + + + + + + + + + + +
КомплектующееСтоимостьКоличествоСуммаДействие
+
+ +
+
+ + + +@section Scripts +{ + +} \ No newline at end of file diff --git a/ComputerHardwareStore/StoreKeeperClient/Views/Storekeeper/LinkBuilds.cshtml b/ComputerHardwareStore/StoreKeeperClient/Views/Storekeeper/LinkBuilds.cshtml new file mode 100644 index 0000000..95e60d1 --- /dev/null +++ b/ComputerHardwareStore/StoreKeeperClient/Views/Storekeeper/LinkBuilds.cshtml @@ -0,0 +1,183 @@ +@using HardwareShopContracts.ViewModels +@{ + ViewData["Title"] = "Привязка сборок"; + Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml"; +} + +
+

Привязка сборок

+
+ +
+
+
+ +
+
+

Привязанные сборки

+ + + + + + + + + + +
СборкаКоличествоДействие
+
+ +
+
+ +