From 0cbba88298356b6be12ef1d70a8635314fba515f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=BB=D1=8C=D1=8F=20=D0=A4=D0=B5=D0=B4=D0=BE=D1=82?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Sat, 1 Jun 2024 05:00:05 +0400 Subject: [PATCH 1/2] =?UTF-8?q?=D1=83=D0=B6=D0=B0=D1=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogic/PaymeantLogic.cs | 2 +- .../BindingModels/PaymeantBindingModel.cs | 2 - ... 20240601002930_InitMigration.Designer.cs} | 7 +-- ...nit.cs => 20240601002930_InitMigration.cs} | 3 +- .../Migrations/DatabaseModelSnapshot.cs | 3 - .../Models/Paymeant.cs | 6 -- .../Models/IPaymentModel.cs | 1 - .../Controllers/ClientController.cs | 14 ++++- .../ElectronicsShopRestAPI/Program.cs | 2 + .../Controllers/HomeController.cs | 47 +++++++++++++--- .../Views/Home/Payment.cshtml | 55 +++++++++++-------- 11 files changed, 88 insertions(+), 54 deletions(-) rename ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/{20240531153626_Init.Designer.cs => 20240601002930_InitMigration.Designer.cs} (98%) rename ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/{20240531153626_Init.cs => 20240601002930_InitMigration.cs} (98%) diff --git a/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/PaymeantLogic.cs b/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/PaymeantLogic.cs index c759895..3a10116 100644 --- a/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/PaymeantLogic.cs +++ b/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/PaymeantLogic.cs @@ -71,7 +71,7 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic { throw new ArgumentNullException("Сумма оплаты должна быть больше 0", nameof(model.SumPayment)); } - _logger.LogInformation($"Payment. ID:{model.ID}.ProductID:{model.ProductID}.Sum:{model.SumPayment}.OrderID:{model.OrderID}" + + _logger.LogInformation($"Payment. ID:{model.ID}.Sum:{model.SumPayment}.OrderID:{model.OrderID}" + $".PayOption{model.PayOption}"); } diff --git a/ElectronicsShop/ElectronicsShopContracts/BindingModels/PaymeantBindingModel.cs b/ElectronicsShop/ElectronicsShopContracts/BindingModels/PaymeantBindingModel.cs index c66dd30..cd7840f 100644 --- a/ElectronicsShop/ElectronicsShopContracts/BindingModels/PaymeantBindingModel.cs +++ b/ElectronicsShop/ElectronicsShopContracts/BindingModels/PaymeantBindingModel.cs @@ -12,8 +12,6 @@ namespace ElectronicsShopContracts.BindingModels { public int ID { get; set; } - public int ProductID { get; set; } - public int OrderID { get; set; } public double SumPayment { get; set; } diff --git a/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240531153626_Init.Designer.cs b/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240601002930_InitMigration.Designer.cs similarity index 98% rename from ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240531153626_Init.Designer.cs rename to ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240601002930_InitMigration.Designer.cs index e9218ef..a04775f 100644 --- a/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240531153626_Init.Designer.cs +++ b/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240601002930_InitMigration.Designer.cs @@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace ElectronicsShopDataBaseImplement.Migrations { [DbContext(typeof(Database))] - [Migration("20240531153626_Init")] - partial class Init + [Migration("20240601002930_InitMigration")] + partial class InitMigration { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -200,9 +200,6 @@ namespace ElectronicsShopDataBaseImplement.Migrations b.Property("PaymentID") .HasColumnType("int"); - b.Property("ProductID") - .HasColumnType("int"); - b.Property("SumPayment") .HasColumnType("float"); diff --git a/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240531153626_Init.cs b/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240601002930_InitMigration.cs similarity index 98% rename from ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240531153626_Init.cs rename to ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240601002930_InitMigration.cs index dc157cf..d34bb38 100644 --- a/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240531153626_Init.cs +++ b/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240601002930_InitMigration.cs @@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ElectronicsShopDataBaseImplement.Migrations { /// - public partial class Init : Migration + public partial class InitMigration : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) @@ -111,7 +111,6 @@ namespace ElectronicsShopDataBaseImplement.Migrations { ID = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), - ProductID = table.Column(type: "int", nullable: false), OrderID = table.Column(type: "int", nullable: false), SumPayment = table.Column(type: "float", nullable: false), PayOption = table.Column(type: "int", nullable: false), diff --git a/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/DatabaseModelSnapshot.cs b/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/DatabaseModelSnapshot.cs index ed01306..bafcd57 100644 --- a/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/DatabaseModelSnapshot.cs +++ b/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/DatabaseModelSnapshot.cs @@ -197,9 +197,6 @@ namespace ElectronicsShopDataBaseImplement.Migrations b.Property("PaymentID") .HasColumnType("int"); - b.Property("ProductID") - .HasColumnType("int"); - b.Property("SumPayment") .HasColumnType("float"); diff --git a/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/Paymeant.cs b/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/Paymeant.cs index ad2accc..8005f9f 100644 --- a/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/Paymeant.cs +++ b/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/Paymeant.cs @@ -17,9 +17,6 @@ namespace ElectronicsShopDataBaseImplement.Models { public int ID { get; set; } - [ForeignKey("ProductID")] - public int ProductID { get; set; } - [ForeignKey("OrderID")] public int OrderID { get; set; } @@ -38,7 +35,6 @@ namespace ElectronicsShopDataBaseImplement.Models return new Paymeant() { ID = model.ID, - ProductID = model.ProductID, OrderID = model.OrderID, SumPayment = model.SumPayment, PayOption = model.PayOption, @@ -50,7 +46,6 @@ namespace ElectronicsShopDataBaseImplement.Models { return; } - ProductID = model.ProductID; OrderID = model.OrderID; SumPayment = model.SumPayment; PayOption = model.PayOption; @@ -59,7 +54,6 @@ namespace ElectronicsShopDataBaseImplement.Models public PaymeantViewModel GetViewModel => new() { ID = ID, - ProductID = ProductID, OrderID = OrderID, SumPayment = SumPayment, PayOption = PayOption, diff --git a/ElectronicsShop/ElectronicsShopDataModels/Models/IPaymentModel.cs b/ElectronicsShop/ElectronicsShopDataModels/Models/IPaymentModel.cs index 269c5e4..77e5897 100644 --- a/ElectronicsShop/ElectronicsShopDataModels/Models/IPaymentModel.cs +++ b/ElectronicsShop/ElectronicsShopDataModels/Models/IPaymentModel.cs @@ -10,7 +10,6 @@ namespace ElectronicsShopDataModels.Models { public interface IPaymentModel: IID { - int ProductID { get; } int OrderID { get; } double SumPayment { get; } PaymeantOption PayOption { get; } diff --git a/ElectronicsShop/ElectronicsShopRestAPI/Controllers/ClientController.cs b/ElectronicsShop/ElectronicsShopRestAPI/Controllers/ClientController.cs index 8ddf38f..843d622 100644 --- a/ElectronicsShop/ElectronicsShopRestAPI/Controllers/ClientController.cs +++ b/ElectronicsShop/ElectronicsShopRestAPI/Controllers/ClientController.cs @@ -13,10 +13,12 @@ namespace ElectronicsShopRestAPI.Controllers { private readonly ILogger _logger; private readonly IClientLogic _logic; + private readonly IPaymeantLogic _payLogic; - public ClientController(ILogger logger, IClientLogic logic) { + public ClientController(ILogger logger, IClientLogic logic, IPaymeantLogic payLogic) { _logger = logger; _logic = logic; + _payLogic = payLogic; } [HttpGet] @@ -54,5 +56,15 @@ namespace ElectronicsShopRestAPI.Controllers { throw; } } + + [HttpPost] + public void CreatePaymeant (PaymeantBindingModel model) { + try { + _payLogic.CreatePay(model); + } + catch (Exception ex) { + _logger.LogError(ex, "Ошибка создания оплаты"); + } + } } } diff --git a/ElectronicsShop/ElectronicsShopRestAPI/Program.cs b/ElectronicsShop/ElectronicsShopRestAPI/Program.cs index 1b0f4c2..7e96a76 100644 --- a/ElectronicsShop/ElectronicsShopRestAPI/Program.cs +++ b/ElectronicsShop/ElectronicsShopRestAPI/Program.cs @@ -15,12 +15,14 @@ builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle diff --git a/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs b/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs index 9a07824..59c1b26 100644 --- a/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs +++ b/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs @@ -2,6 +2,7 @@ using ElectronicsShopContracts.BindingModels; using ElectronicsShopContracts.BusinessLogicContracts; using ElectronicsShopContracts.SearchModels; using ElectronicsShopContracts.ViewModels; +using ElectronicsShopDataModels.Enums; using ElectronicsShopDataModels.Models; using ElectronicsShopUserApp.Models; using Microsoft.AspNetCore.Mvc; @@ -150,7 +151,7 @@ namespace ElectronicsShopUserApp.Controllers { } [HttpPost] - public void EditOrder(int sum, int id) { + public void EditOrder(double sum, int id) { if (sum <= 0) { APIClient.PostRequest($"api/main/deleteorders", new OrderBindingModel { ID = id }); } @@ -181,7 +182,7 @@ namespace ElectronicsShopUserApp.Controllers { } [HttpPost] - public void OrderView(int sum, int id) { + public void OrderView(double sum, int id) { if (sum <= 0) { APIClient.PostRequest($"api/main/deleteorders", new OrderBindingModel { ID = id}); } @@ -211,12 +212,6 @@ namespace ElectronicsShopUserApp.Controllers { Response.Redirect("OrderView"); } - [HttpPost] - public double Calc(int count, int product) - { - var _product = APIClient.GetRequset($"api/main/getproduct?_productid={product}"); - return count * (_product?.Price ?? 1); - } [HttpGet] public IActionResult Report() { @@ -233,6 +228,8 @@ namespace ElectronicsShopUserApp.Controllers { //ViewBag.Reports = APIClient.GetRequset>($"api/main/getproducts"); return View(); } + + [HttpGet] public IActionResult Payment(int id) { if (APIClient.Client == null) @@ -242,7 +239,7 @@ namespace ElectronicsShopUserApp.Controllers { if (id == 0) { - return Redirect("Orders"); + return Redirect("~/Home/Index"); } var products = APIClient.GetRequset>>($"api/main/getorderproducts?_orderid={id}"); @@ -256,6 +253,38 @@ namespace ElectronicsShopUserApp.Controllers { (int, Dictionary) tuple = (id, _productList); return View(tuple); } + + [HttpPost] + public void Payment(double sum, double paysum, int id) { + if (APIClient.Client == null) { + throw new Exception(" "); + } + if (paysum <= 0) { + throw new Exception(" 0"); + } + if (paysum > sum) { + throw new Exception(" "); + } + APIClient.PostRequest("api/client/createpaymeant", new PaymeantBindingModel { + OrderID = id, + SumPayment = sum, + PayOption = PayOptionCalc(sum, paysum) + }); + Response.Redirect("Index"); + } + + [HttpPost] + public PaymeantOption PayOptionCalc(double sum, double paysum) { + if (paysum < sum) { + return PaymeantOption._; + } + else if (paysum == sum) { + return PaymeantOption._; + } + else { + return PaymeantOption.; + } + } } } diff --git a/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/Payment.cshtml b/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/Payment.cshtml index 625e2c6..a978530 100644 --- a/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/Payment.cshtml +++ b/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/Payment.cshtml @@ -16,17 +16,23 @@
-
-
Сумма платежа:
-
- - -
-
-
+
+
Сумма платежа:
+
+ +
+ +
+
+
Сумма к оплате:
+
+ + + +
@@ -70,28 +76,29 @@ - + \ No newline at end of file From c3c37efef6118db81ee1db5e1b0b2acd432b35bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=BB=D1=8C=D1=8F=20=D0=A4=D0=B5=D0=B4=D0=BE=D1=82?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Sat, 1 Jun 2024 05:23:37 +0400 Subject: [PATCH 2/2] Paymeant is done --- .../BusinessLogic/ReportClientLogic.cs | 2 +- .../BindingModels/PaymeantBindingModel.cs | 2 ++ .../SearchModels/PaymeantSearchModel.cs | 1 + .../ViewModels/PaymeantViewModel.cs | 7 ++++--- .../Implements/PaymeantStorage.cs | 5 +++++ ... => 20240601012156_InitMigration.Designer.cs} | 5 ++++- ...ration.cs => 20240601012156_InitMigration.cs} | 1 + .../Migrations/DatabaseModelSnapshot.cs | 3 +++ .../Models/Paymeant.cs | 8 ++++++-- .../Models/IPaymentModel.cs | 1 + .../Controllers/ClientController.cs | 11 +++++++++++ .../Controllers/HomeController.cs | 7 ++++--- .../Views/Home/Index.cshtml | 16 +++++++++++----- 13 files changed, 54 insertions(+), 15 deletions(-) rename ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/{20240601002930_InitMigration.Designer.cs => 20240601012156_InitMigration.Designer.cs} (98%) rename ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/{20240601002930_InitMigration.cs => 20240601012156_InitMigration.cs} (99%) diff --git a/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportClientLogic.cs b/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportClientLogic.cs index e6bb4c3..9cf04ff 100644 --- a/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportClientLogic.cs +++ b/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportClientLogic.cs @@ -29,7 +29,7 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic var record = new ReportPaymeantsViewModel { PaymeantID=paymeant.ID, - ProductID=paymeant.ProductID, + //ProductID=paymeant.ProductID, OrderID=paymeant.OrderID, PayOption=paymeant.PayOption, SumPayment=paymeant.SumPayment, diff --git a/ElectronicsShop/ElectronicsShopContracts/BindingModels/PaymeantBindingModel.cs b/ElectronicsShop/ElectronicsShopContracts/BindingModels/PaymeantBindingModel.cs index cd7840f..30c11b3 100644 --- a/ElectronicsShop/ElectronicsShopContracts/BindingModels/PaymeantBindingModel.cs +++ b/ElectronicsShop/ElectronicsShopContracts/BindingModels/PaymeantBindingModel.cs @@ -17,5 +17,7 @@ namespace ElectronicsShopContracts.BindingModels public double SumPayment { get; set; } public PaymeantOption PayOption { get; set; } = PaymeantOption.Неоплачено; + + public int ClientID { get; set; } } } diff --git a/ElectronicsShop/ElectronicsShopContracts/SearchModels/PaymeantSearchModel.cs b/ElectronicsShop/ElectronicsShopContracts/SearchModels/PaymeantSearchModel.cs index 6332616..450909c 100644 --- a/ElectronicsShop/ElectronicsShopContracts/SearchModels/PaymeantSearchModel.cs +++ b/ElectronicsShop/ElectronicsShopContracts/SearchModels/PaymeantSearchModel.cs @@ -12,5 +12,6 @@ namespace ElectronicsShopContracts.SearchModels public int? ProductID { get; set; } public int? OrderID { get; set; } public double? SumPay { get; set; } + public int? ClientID { get; set; } } } diff --git a/ElectronicsShop/ElectronicsShopContracts/ViewModels/PaymeantViewModel.cs b/ElectronicsShop/ElectronicsShopContracts/ViewModels/PaymeantViewModel.cs index 995f035..b26ba1e 100644 --- a/ElectronicsShop/ElectronicsShopContracts/ViewModels/PaymeantViewModel.cs +++ b/ElectronicsShop/ElectronicsShopContracts/ViewModels/PaymeantViewModel.cs @@ -12,8 +12,6 @@ namespace ElectronicsShopContracts.ViewModels public class PaymeantViewModel : IPaymentModel { public int ID { get; set; } - public int ProductID { get; set; } - public int OrderID { get; set; } [DisplayName("Cумма оплаты продукта")] @@ -21,5 +19,8 @@ namespace ElectronicsShopContracts.ViewModels [DisplayName("Статус оплаты")] public PaymeantOption PayOption { get; set; } = PaymeantOption.Неоплачено; - } + + [DisplayName("Клиент")] + public int ClientID { get; set; } + } } diff --git a/ElectronicsShop/ElectronicsShopDataBaseImplement/Implements/PaymeantStorage.cs b/ElectronicsShop/ElectronicsShopDataBaseImplement/Implements/PaymeantStorage.cs index f3d10a9..0445b3d 100644 --- a/ElectronicsShop/ElectronicsShopDataBaseImplement/Implements/PaymeantStorage.cs +++ b/ElectronicsShop/ElectronicsShopDataBaseImplement/Implements/PaymeantStorage.cs @@ -48,6 +48,11 @@ namespace ElectronicsShopDataBaseImplement.Implements { return new(); } using var context = new Database(); + if (model.ClientID.HasValue) { + return context.Paymeants + .Where(x => x.ClientID == model.ClientID) + .Select(x => x.GetViewModel).ToList(); + } return context.Paymeants .Where(x => x.ID == model.ID) .Select(x => x.GetViewModel).ToList(); diff --git a/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240601002930_InitMigration.Designer.cs b/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240601012156_InitMigration.Designer.cs similarity index 98% rename from ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240601002930_InitMigration.Designer.cs rename to ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240601012156_InitMigration.Designer.cs index a04775f..31a2e6b 100644 --- a/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240601002930_InitMigration.Designer.cs +++ b/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240601012156_InitMigration.Designer.cs @@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace ElectronicsShopDataBaseImplement.Migrations { [DbContext(typeof(Database))] - [Migration("20240601002930_InitMigration")] + [Migration("20240601012156_InitMigration")] partial class InitMigration { /// @@ -191,6 +191,9 @@ namespace ElectronicsShopDataBaseImplement.Migrations SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); + b.Property("ClientID") + .HasColumnType("int"); + b.Property("OrderID") .HasColumnType("int"); diff --git a/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240601002930_InitMigration.cs b/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240601012156_InitMigration.cs similarity index 99% rename from ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240601002930_InitMigration.cs rename to ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240601012156_InitMigration.cs index d34bb38..780ffb3 100644 --- a/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240601002930_InitMigration.cs +++ b/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240601012156_InitMigration.cs @@ -112,6 +112,7 @@ namespace ElectronicsShopDataBaseImplement.Migrations ID = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), OrderID = table.Column(type: "int", nullable: false), + ClientID = table.Column(type: "int", nullable: false), SumPayment = table.Column(type: "float", nullable: false), PayOption = table.Column(type: "int", nullable: false), PaymentID = table.Column(type: "int", nullable: true) diff --git a/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/DatabaseModelSnapshot.cs b/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/DatabaseModelSnapshot.cs index bafcd57..0869eef 100644 --- a/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/DatabaseModelSnapshot.cs +++ b/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/DatabaseModelSnapshot.cs @@ -188,6 +188,9 @@ namespace ElectronicsShopDataBaseImplement.Migrations SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); + b.Property("ClientID") + .HasColumnType("int"); + b.Property("OrderID") .HasColumnType("int"); diff --git a/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/Paymeant.cs b/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/Paymeant.cs index 8005f9f..851e53c 100644 --- a/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/Paymeant.cs +++ b/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/Paymeant.cs @@ -21,6 +21,9 @@ namespace ElectronicsShopDataBaseImplement.Models public int OrderID { get; set; } [Required] + public int ClientID { get; set; } + + [Required] public double SumPayment { get; set; } [Required] @@ -38,6 +41,7 @@ namespace ElectronicsShopDataBaseImplement.Models OrderID = model.OrderID, SumPayment = model.SumPayment, PayOption = model.PayOption, + ClientID = model.ClientID, }; } public void Update(PaymeantBindingModel? model) @@ -57,7 +61,7 @@ namespace ElectronicsShopDataBaseImplement.Models OrderID = OrderID, SumPayment = SumPayment, PayOption = PayOption, + ClientID = ClientID, }; - - } + } } diff --git a/ElectronicsShop/ElectronicsShopDataModels/Models/IPaymentModel.cs b/ElectronicsShop/ElectronicsShopDataModels/Models/IPaymentModel.cs index 77e5897..1170593 100644 --- a/ElectronicsShop/ElectronicsShopDataModels/Models/IPaymentModel.cs +++ b/ElectronicsShop/ElectronicsShopDataModels/Models/IPaymentModel.cs @@ -13,5 +13,6 @@ namespace ElectronicsShopDataModels.Models int OrderID { get; } double SumPayment { get; } PaymeantOption PayOption { get; } + int ClientID { get; } } } diff --git a/ElectronicsShop/ElectronicsShopRestAPI/Controllers/ClientController.cs b/ElectronicsShop/ElectronicsShopRestAPI/Controllers/ClientController.cs index 843d622..8598ce9 100644 --- a/ElectronicsShop/ElectronicsShopRestAPI/Controllers/ClientController.cs +++ b/ElectronicsShop/ElectronicsShopRestAPI/Controllers/ClientController.cs @@ -66,5 +66,16 @@ namespace ElectronicsShopRestAPI.Controllers { _logger.LogError(ex, "Ошибка создания оплаты"); } } + + [HttpPost] + public List? GetPaymeants(int _clientID) { + try { + return _payLogic.ReadList(new PaymeantSearchModel { ClientID = _clientID }); + } + catch (Exception ex) { + _logger.LogError(ex, $"Ошибка получения списка оплат клиента id = {_clientID}"); + throw; + } + } } } diff --git a/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs b/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs index 59c1b26..2ceec77 100644 --- a/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs +++ b/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs @@ -29,7 +29,7 @@ namespace ElectronicsShopUserApp.Controllers { if (APIClient.Client == null) { return Redirect("~/Home/Enter"); } - return View(APIClient.GetRequset>($"api/main/getorders?_clientid={APIClient.Client.ID}")); + return View(APIClient.GetRequset>($"api/client/getpaymeants?_clientid={APIClient.Client.ID}")); } [HttpGet] @@ -267,8 +267,9 @@ namespace ElectronicsShopUserApp.Controllers { } APIClient.PostRequest("api/client/createpaymeant", new PaymeantBindingModel { OrderID = id, - SumPayment = sum, - PayOption = PayOptionCalc(sum, paysum) + SumPayment = paysum, + PayOption = PayOptionCalc(sum, paysum), + ClientID = APIClient.Client.ID }); Response.Redirect("Index"); } diff --git a/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/Index.cshtml b/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/Index.cshtml index 3464ddf..ff68e3e 100644 --- a/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/Index.cshtml +++ b/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/Index.cshtml @@ -1,6 +1,6 @@ @using ElectronicsShopContracts.ViewModels -@model List +@model List @{ ViewData["Title"] = "Home Page"; @@ -20,14 +20,17 @@
+ @@ -38,10 +41,13 @@ @Html.DisplayFor(modelItem => item.ID) + }
+ Номер + Номер заказа - Дата создания + Сумма к оплате - Сумма + Статус оплаты
- @Html.DisplayFor(modelItem => item.DateCreate) + @Html.DisplayFor(modelItem => item.OrderID) - @Html.DisplayFor(modelItem => item.Sum) + @Html.DisplayFor(modelItem => item.SumPayment) + + @Html.DisplayFor(modelItem => item.PayOption)