diff --git a/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/PaymeantLogic.cs b/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/PaymeantLogic.cs index 189f26f..b486a52 100644 --- a/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/PaymeantLogic.cs +++ b/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/PaymeantLogic.cs @@ -71,8 +71,11 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic { throw new ArgumentNullException("Сумма оплаты должна быть больше 0", nameof(model.SumPayment)); } + if (model.PayProductList.Count == 0) { + throw new ArgumentNullException("нельзя оплатить пустой заказ", nameof(model.PayProductList)); + } _logger.LogInformation($"Payment. ID:{model.ID}.Sum:{model.SumPayment}.OrderID:{model.OrderID}" + - $".PayOption{model.PayOption}"); + $".PayOption{model.PayOption}.Products:{model.PayProductList}"); } public bool SetFullPayment(PaymeantBindingModel model) { diff --git a/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportClientLogic.cs b/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportClientLogic.cs index 921b703..4ce86d5 100644 --- a/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportClientLogic.cs +++ b/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportClientLogic.cs @@ -44,13 +44,12 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic List? products = new(); foreach (var paymeant in paymeants) { - var order = _orderStorage.GetElement(new OrderSearchModel { ID = paymeant.OrderID }); - foreach (var product in order.ProductList) { + foreach (var product in paymeant.PayProductList) { products.Add(new ReportProductsViewModel { ID = product.Value.Item1.ID, ProductName = product.Value.Item1.ProductName, Price = product.Value.Item1.Price, - CostItemName = _costItemStorage.GetElement(new CostItemSearchModel { ID = product.Value.Item1.CostItemID })?.Name + CostItemName = _costItemStorage.GetElement(new CostItemSearchModel { ID = product.Value.Item1.CostItemID })?.Name ?? "Отсутствует" }); } @@ -89,17 +88,11 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic TotalCount = 0 }; - var order = _orderStorage.GetElement(new OrderSearchModel { ID = paymeant.OrderID }); - if (order == null) { - continue; + foreach (var product in paymeant.PayProductList) { + record.Products.Add(new(product.Value.Item1.ProductName, product.Value.Item2)); + record.TotalCount += product.Value.Item2; } - foreach (var product in products) { - if (order.ProductList.ContainsKey(product.ID)) { - record.Products.Add(new(product.ProductName, order.ProductList[product.ID].Item2)); - record.TotalCount += order.ProductList[product.ID].Item2; - } - } list.Add(record); } diff --git a/ElectronicsShop/ElectronicsShopContracts/BindingModels/PaymeantBindingModel.cs b/ElectronicsShop/ElectronicsShopContracts/BindingModels/PaymeantBindingModel.cs index 4b4d9c8..e02d423 100644 --- a/ElectronicsShop/ElectronicsShopContracts/BindingModels/PaymeantBindingModel.cs +++ b/ElectronicsShop/ElectronicsShopContracts/BindingModels/PaymeantBindingModel.cs @@ -21,5 +21,7 @@ namespace ElectronicsShopContracts.BindingModels public int ClientID { get; set; } public DateTime DatePaymeant { get; set; } = DateTime.Now; - } + + public Dictionary PayProductList { get; set; } = new(); + } } diff --git a/ElectronicsShop/ElectronicsShopContracts/ViewModels/MessageInfoViewModel.cs b/ElectronicsShop/ElectronicsShopContracts/ViewModels/MessageInfoViewModel.cs deleted file mode 100644 index 8b634e3..0000000 --- a/ElectronicsShop/ElectronicsShopContracts/ViewModels/MessageInfoViewModel.cs +++ /dev/null @@ -1,30 +0,0 @@ -using ElectronicsShopDataModels.Models; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ElectronicsShopContracts.ViewModels -{ - public class MessageInfoViewModel: IMessageInfoModel - { - public string MessageID { get; set; } = string.Empty; - - public int? ClientID { get; set; } - - [DisplayName("Отправитель")] - public string SenderName { get; set; } = string.Empty; - - [DisplayName("Дата письма")] - public DateTime DateDelivery { get; set; } - - [DisplayName("Заголовок")] - public string Subject { get; set; } = string.Empty; - - [DisplayName("Текст")] - public string Body { get; set; } = string.Empty; - } -} - diff --git a/ElectronicsShop/ElectronicsShopContracts/ViewModels/PaymeantViewModel.cs b/ElectronicsShop/ElectronicsShopContracts/ViewModels/PaymeantViewModel.cs index 5894898..c93e9d7 100644 --- a/ElectronicsShop/ElectronicsShopContracts/ViewModels/PaymeantViewModel.cs +++ b/ElectronicsShop/ElectronicsShopContracts/ViewModels/PaymeantViewModel.cs @@ -24,5 +24,8 @@ namespace ElectronicsShopContracts.ViewModels public int ClientID { get; set; } public DateTime DatePaymeant { get; set; } - } + + [DisplayName("Список оплаченных товаров")] + public Dictionary PayProductList { get; set; } = new(); + } } diff --git a/ElectronicsShop/ElectronicsShopDataBaseImplement/Implements/OrderStorage.cs b/ElectronicsShop/ElectronicsShopDataBaseImplement/Implements/OrderStorage.cs index 9737bba..366e532 100644 --- a/ElectronicsShop/ElectronicsShopDataBaseImplement/Implements/OrderStorage.cs +++ b/ElectronicsShop/ElectronicsShopDataBaseImplement/Implements/OrderStorage.cs @@ -67,6 +67,7 @@ namespace ElectronicsShopDataBaseImplement.Implements using var context = new Database(); if (model.ClientID.HasValue) { return context.Orders + .Include(x => x.Payments) .Include(x => x.Products) .ThenInclude(x => x._product) .OrderBy(x => x.ID) @@ -75,7 +76,8 @@ namespace ElectronicsShopDataBaseImplement.Implements if (model.ID.HasValue) { return context.Orders - .Include(x => x.Products) + .Include(x => x.Payments) + .Include(x => x.Products) .ThenInclude(x => x._product) .FirstOrDefault(x => (model.ID.HasValue && x.ID == model.ID))?.GetViewModel; } diff --git a/ElectronicsShop/ElectronicsShopDataBaseImplement/Implements/PaymeantStorage.cs b/ElectronicsShop/ElectronicsShopDataBaseImplement/Implements/PaymeantStorage.cs index 13c519f..0f6559c 100644 --- a/ElectronicsShop/ElectronicsShopDataBaseImplement/Implements/PaymeantStorage.cs +++ b/ElectronicsShop/ElectronicsShopDataBaseImplement/Implements/PaymeantStorage.cs @@ -25,6 +25,7 @@ namespace ElectronicsShopDataBaseImplement.Implements { return newPayment.GetViewModel; } + // todo тут должен меняться статус оплаты public PaymeantViewModel? UpdatePay(PaymeantBindingModel model) { using var context = new Database(); var paymeant = context.Paymeants.FirstOrDefault(x => x.ID == model.ID); diff --git a/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240724085609_05.Designer.cs b/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240724085609_05.Designer.cs new file mode 100644 index 0000000..ad2389d --- /dev/null +++ b/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240724085609_05.Designer.cs @@ -0,0 +1,285 @@ +// +using System; +using ElectronicsShopDataBaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace ElectronicsShopDataBaseImplement.Migrations +{ + [DbContext(typeof(Database))] + [Migration("20240724085609_05")] + partial class _05 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("ElectronicsShopDataBaseImplement.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("ElectronicsShopDataBaseImplement.Models.CostItem", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); + + b.Property("CostNum") + .HasColumnType("int"); + + b.Property("EmployeeID") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("float"); + + b.HasKey("ID"); + + b.HasIndex("EmployeeID"); + + b.ToTable("CostItems"); + }); + + modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Employee", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); + + b.Property("EmployeeFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Login") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ID"); + + b.ToTable("Employees"); + }); + + modelBuilder.Entity("ElectronicsShopDataBaseImplement.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("Sum") + .HasColumnType("float"); + + b.HasKey("ID"); + + b.HasIndex("ClientID"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.OrderProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("OrderID") + .HasColumnType("int"); + + b.Property("ProductID") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("OrderID"); + + b.HasIndex("ProductID"); + + b.ToTable("OrderProducts"); + }); + + modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Paymeant", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); + + b.Property("ClientID") + .HasColumnType("int"); + + b.Property("DatePaymeant") + .HasColumnType("datetime2"); + + b.Property("OrderID") + .HasColumnType("int"); + + b.Property("PayOption") + .HasColumnType("int"); + + b.Property("PaymentID") + .HasColumnType("int"); + + b.Property("SumPayment") + .HasColumnType("float"); + + b.HasKey("ID"); + + b.HasIndex("PaymentID"); + + b.ToTable("Paymeants"); + }); + + modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Product", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); + + b.Property("CostItemID") + .HasColumnType("int"); + + b.Property("Price") + .HasColumnType("float"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ID"); + + b.HasIndex("CostItemID"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.CostItem", b => + { + b.HasOne("ElectronicsShopDataBaseImplement.Models.Employee", "Employee") + .WithMany() + .HasForeignKey("EmployeeID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Employee"); + }); + + modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Order", b => + { + b.HasOne("ElectronicsShopDataBaseImplement.Models.Client", null) + .WithMany("Orders") + .HasForeignKey("ClientID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.OrderProduct", b => + { + b.HasOne("ElectronicsShopDataBaseImplement.Models.Order", "_order") + .WithMany("Products") + .HasForeignKey("OrderID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("ElectronicsShopDataBaseImplement.Models.Product", "_product") + .WithMany() + .HasForeignKey("ProductID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("_order"); + + b.Navigation("_product"); + }); + + modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Paymeant", b => + { + b.HasOne("ElectronicsShopDataBaseImplement.Models.Order", null) + .WithMany("Payments") + .HasForeignKey("PaymentID"); + }); + + modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Product", b => + { + b.HasOne("ElectronicsShopDataBaseImplement.Models.CostItem", "CostItem") + .WithMany() + .HasForeignKey("CostItemID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CostItem"); + }); + + modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Client", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Order", b => + { + b.Navigation("Payments"); + + b.Navigation("Products"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240724085609_05.cs b/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240724085609_05.cs new file mode 100644 index 0000000..2efbda7 --- /dev/null +++ b/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240724085609_05.cs @@ -0,0 +1,48 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace ElectronicsShopDataBaseImplement.Migrations +{ + /// + public partial class _05 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "PaymentID", + table: "Paymeants", + type: "int", + nullable: true); + + migrationBuilder.CreateIndex( + name: "IX_Paymeants_PaymentID", + table: "Paymeants", + column: "PaymentID"); + + migrationBuilder.AddForeignKey( + name: "FK_Paymeants_Orders_PaymentID", + table: "Paymeants", + column: "PaymentID", + principalTable: "Orders", + principalColumn: "ID"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Paymeants_Orders_PaymentID", + table: "Paymeants"); + + migrationBuilder.DropIndex( + name: "IX_Paymeants_PaymentID", + table: "Paymeants"); + + migrationBuilder.DropColumn( + name: "PaymentID", + table: "Paymeants"); + } + } +} diff --git a/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/DatabaseModelSnapshot.cs b/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/DatabaseModelSnapshot.cs index c26ec3b..21e0b9b 100644 --- a/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/DatabaseModelSnapshot.cs +++ b/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/DatabaseModelSnapshot.cs @@ -44,7 +44,7 @@ namespace ElectronicsShopDataBaseImplement.Migrations b.HasKey("ID"); - b.ToTable("Clients", (string)null); + b.ToTable("Clients"); }); modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.CostItem", b => @@ -72,7 +72,7 @@ namespace ElectronicsShopDataBaseImplement.Migrations b.HasIndex("EmployeeID"); - b.ToTable("CostItems", (string)null); + b.ToTable("CostItems"); }); modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Employee", b => @@ -97,7 +97,7 @@ namespace ElectronicsShopDataBaseImplement.Migrations b.HasKey("ID"); - b.ToTable("Employees", (string)null); + b.ToTable("Employees"); }); modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Order", b => @@ -121,7 +121,7 @@ namespace ElectronicsShopDataBaseImplement.Migrations b.HasIndex("ClientID"); - b.ToTable("Orders", (string)null); + b.ToTable("Orders"); }); modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.OrderProduct", b => @@ -147,7 +147,7 @@ namespace ElectronicsShopDataBaseImplement.Migrations b.HasIndex("ProductID"); - b.ToTable("OrderProducts", (string)null); + b.ToTable("OrderProducts"); }); modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Paymeant", b => @@ -170,12 +170,17 @@ namespace ElectronicsShopDataBaseImplement.Migrations b.Property("PayOption") .HasColumnType("int"); + b.Property("PaymentID") + .HasColumnType("int"); + b.Property("SumPayment") .HasColumnType("float"); b.HasKey("ID"); - b.ToTable("Paymeants", (string)null); + b.HasIndex("PaymentID"); + + b.ToTable("Paymeants"); }); modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Product", b => @@ -200,7 +205,7 @@ namespace ElectronicsShopDataBaseImplement.Migrations b.HasIndex("CostItemID"); - b.ToTable("Products", (string)null); + b.ToTable("Products"); }); modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.CostItem", b => @@ -242,6 +247,13 @@ namespace ElectronicsShopDataBaseImplement.Migrations b.Navigation("_product"); }); + modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Paymeant", b => + { + b.HasOne("ElectronicsShopDataBaseImplement.Models.Order", null) + .WithMany("Payments") + .HasForeignKey("PaymentID"); + }); + modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Product", b => { b.HasOne("ElectronicsShopDataBaseImplement.Models.CostItem", "CostItem") @@ -260,6 +272,8 @@ namespace ElectronicsShopDataBaseImplement.Migrations modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Order", b => { + b.Navigation("Payments"); + b.Navigation("Products"); }); #pragma warning restore 612, 618 diff --git a/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/Order.cs b/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/Order.cs index 5322763..13c1ddd 100644 --- a/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/Order.cs +++ b/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/Order.cs @@ -43,7 +43,10 @@ namespace ElectronicsShopDataBaseImplement.Models [ForeignKey("OrderID")] public virtual List Products { get; set; } = new(); - public static Order? Create(Database context ,OrderBindingModel? model) + [ForeignKey("PaymentID")] + public virtual List Payments { get; set; } = new(); + + public static Order? Create(Database context ,OrderBindingModel? model) { if (model == null) { @@ -107,5 +110,9 @@ namespace ElectronicsShopDataBaseImplement.Models context.OrderProducts.RemoveRange(orderProducts.Where(rec => !model.ProductList.ContainsKey(rec.ProductID))); context.SaveChanges(); } + + public void SumUpdate(double sumDeduct) { + Sum -= sumDeduct; + } } } diff --git a/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/Paymeant.cs b/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/Paymeant.cs index cb82a41..04f53fc 100644 --- a/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/Paymeant.cs +++ b/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/Paymeant.cs @@ -31,7 +31,10 @@ namespace ElectronicsShopDataBaseImplement.Models public DateTime DatePaymeant { get; set; } - public static Paymeant? Create(PaymeantBindingModel? model) + [NotMapped] + public Dictionary PayProductList { get; set; } = new(); + + public static Paymeant? Create(PaymeantBindingModel? model) { if (model == null) { @@ -44,7 +47,8 @@ namespace ElectronicsShopDataBaseImplement.Models SumPayment = model.SumPayment, PayOption = model.PayOption, ClientID = model.ClientID, - DatePaymeant = model.DatePaymeant + DatePaymeant = model.DatePaymeant, + PayProductList = model.PayProductList }; } public void Update(PaymeantBindingModel? model) @@ -53,7 +57,6 @@ namespace ElectronicsShopDataBaseImplement.Models { return; } - OrderID = model.OrderID; SumPayment = model.SumPayment; PayOption = model.PayOption; } @@ -64,7 +67,8 @@ namespace ElectronicsShopDataBaseImplement.Models SumPayment = SumPayment, PayOption = PayOption, ClientID = ClientID, - DatePaymeant = DatePaymeant + DatePaymeant = DatePaymeant, + PayProductList = PayProductList }; - } + } } diff --git a/ElectronicsShop/ElectronicsShopDataModels/Models/IMessageInfoModel.cs b/ElectronicsShop/ElectronicsShopDataModels/Models/IMessageInfoModel.cs deleted file mode 100644 index 2baae7e..0000000 --- a/ElectronicsShop/ElectronicsShopDataModels/Models/IMessageInfoModel.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ElectronicsShopDataModels.Models -{ - public interface IMessageInfoModel - { - string MessageID { get; } - - int? ClientID { get; } - - string SenderName { get; } - - DateTime DateDelivery { get; } - - string Subject { get; } - - string Body { get; } - } -} diff --git a/ElectronicsShop/ElectronicsShopDataModels/Models/IPaymentModel.cs b/ElectronicsShop/ElectronicsShopDataModels/Models/IPaymentModel.cs index 3e31d6b..e1e1e56 100644 --- a/ElectronicsShop/ElectronicsShopDataModels/Models/IPaymentModel.cs +++ b/ElectronicsShop/ElectronicsShopDataModels/Models/IPaymentModel.cs @@ -15,5 +15,8 @@ namespace ElectronicsShopDataModels.Models PaymeantOption PayOption { get; } DateTime DatePaymeant { get; } int ClientID { get; } - } + + // Список оплаченнх товаров + Dictionary PayProductList { get; } + } } diff --git a/ElectronicsShop/ElectronicsShopEmployeeApp/Controllers/HomeController.cs b/ElectronicsShop/ElectronicsShopEmployeeApp/Controllers/HomeController.cs index 496d352..55503d8 100644 --- a/ElectronicsShop/ElectronicsShopEmployeeApp/Controllers/HomeController.cs +++ b/ElectronicsShop/ElectronicsShopEmployeeApp/Controllers/HomeController.cs @@ -180,8 +180,6 @@ namespace ElectronicsShopEmployeeApp.Controllers { } } - - Response.Redirect("CostItem"); } diff --git a/ElectronicsShop/ElectronicsShopRestAPI/Controllers/ClientController.cs b/ElectronicsShop/ElectronicsShopRestAPI/Controllers/ClientController.cs index 94da2b5..d5a0eaa 100644 --- a/ElectronicsShop/ElectronicsShopRestAPI/Controllers/ClientController.cs +++ b/ElectronicsShop/ElectronicsShopRestAPI/Controllers/ClientController.cs @@ -8,6 +8,7 @@ using ElectronicsShopContracts.SearchModels; using ElectronicsShopContracts.ViewModels; using ElectronicsShopDataBaseImplement.Models; using Microsoft.AspNetCore.Mvc; +using Microsoft.Identity.Client; using MigraDoc.Rendering; namespace ElectronicsShopRestAPI.Controllers { @@ -21,14 +22,16 @@ namespace ElectronicsShopRestAPI.Controllers { private readonly IClientLogic _logic; private readonly IPaymeantLogic _payLogic; private readonly IReportClientLogic _reportLogic; + private readonly IOrderLogic _orderLogic; private readonly AbstractMailWorker _mailWorker; public ClientController(ILogger logger, IClientLogic logic, IPaymeantLogic payLogic, IReportClientLogic reportlogic, - AbstractMailWorker mailWorker) { + IOrderLogic orderLogic, AbstractMailWorker mailWorker) { _logger = logger; _logic = logic; _payLogic = payLogic; _reportLogic = reportlogic; + _orderLogic = orderLogic; _mailWorker = mailWorker; } @@ -71,7 +74,19 @@ namespace ElectronicsShopRestAPI.Controllers { [HttpPost] public void CreatePaymeant (PaymeantBindingModel model) { try { + var products = _orderLogic.ReadElement(new OrderSearchModel { ID = model.OrderID })?.ProductList; + + if (products == null) { + throw new Exception("Ошибка получения товаров"); + } + + model.PayProductList = products; _payLogic.CreatePay(model); + + if (model.PayOption == 0) { + _orderLogic.Delete(new OrderBindingModel { ID = model.OrderID}); + } + } catch (Exception ex) { _logger.LogError(ex, "Ошибка создания оплаты"); diff --git a/ElectronicsShop/ElectronicsShopRestAPI/Controllers/MainController.cs b/ElectronicsShop/ElectronicsShopRestAPI/Controllers/MainController.cs index 1405d1d..a043b3b 100644 --- a/ElectronicsShop/ElectronicsShopRestAPI/Controllers/MainController.cs +++ b/ElectronicsShop/ElectronicsShopRestAPI/Controllers/MainController.cs @@ -21,8 +21,6 @@ namespace ElectronicsShopRestAPI.Controllers { private readonly IPaymeantLogic _paymeant; private readonly IReportClientLogic _reportClientLogic; - //private readonly IMessageInfoLogic _message; - private Dictionary _productlist; public MainController(ILogger logger, IProductLogic product, diff --git a/ElectronicsShop/ElectronicsShopRestAPI/Report b/ElectronicsShop/ElectronicsShopRestAPI/Report index 3e30b7e..ee30878 100644 Binary files a/ElectronicsShop/ElectronicsShopRestAPI/Report and b/ElectronicsShop/ElectronicsShopRestAPI/Report differ diff --git a/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/Message.cshtml b/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/Message.cshtml deleted file mode 100644 index d5ca5c4..0000000 --- a/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/Message.cshtml +++ /dev/null @@ -1,48 +0,0 @@ -@using ElectronicsShopContracts.ViewModels - -@model List -@{ - ViewData["Title"] = "Message"; -} - -
-

Письма

-
-
- @{ - - - - - - - - - - @if (Model != null) - { - @foreach (var item in Model) - { - - - - - } - } - -
- Заголовок - - Тело письма - - Дата письма -
- - @Html.DisplayFor(modelItem => item.Subject) - - @Html.DisplayFor(modelItem => item.Body) - - @Html.DisplayFor(modelItem => item.DateDelivery) -
- } -
\ No newline at end of file diff --git a/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/Payment.cshtml b/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/Payment.cshtml index 04f0ab2..8d0740c 100644 --- a/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/Payment.cshtml +++ b/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/Payment.cshtml @@ -30,7 +30,7 @@
Сумма к оплате:
- +