From ab9da1c1de5f74abff721e3eaa0c6a593ec70cfa Mon Sep 17 00:00:00 2001 From: Yuee Shiness Date: Fri, 19 May 2023 16:02:23 +0400 Subject: [PATCH] RestAPI/logic fixes. --- .../OfficePackage/AbstractSaveToWord.cs | 4 ++-- ComputerStoreDatabaseImplement/Models/PC.cs | 4 +++- ComputerStoreRestAPI/Program.cs | 8 ++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ComputerStoreBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/ComputerStoreBusinessLogic/OfficePackage/AbstractSaveToWord.cs index af0b886..2d7aef7 100644 --- a/ComputerStoreBusinessLogic/OfficePackage/AbstractSaveToWord.cs +++ b/ComputerStoreBusinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -34,11 +34,11 @@ namespace ComputerStoreBusinessLogic.OfficePackage } }); - foreach(var products in consigment.ConsignmentProducts) + foreach(var products in consigment.Products) { CreateParagraph(new WordParagraph { - Texts = new List<(string, WordTextProperties)> { (products.Value.Item1.Name, new WordTextProperties { Bold = true, Size = "24", }), ($" {products.Value.Item1.Price}", new WordTextProperties { Bold = true, Size = "24", }) }, + Texts = new List<(string, WordTextProperties)> { (products.product, new WordTextProperties { Bold = true, Size = "24", }), ($" {products.count}", new WordTextProperties { Bold = true, Size = "24", }) }, TextProperties = new WordTextProperties { Size = "24", diff --git a/ComputerStoreDatabaseImplement/Models/PC.cs b/ComputerStoreDatabaseImplement/Models/PC.cs index 6495324..914d5ed 100644 --- a/ComputerStoreDatabaseImplement/Models/PC.cs +++ b/ComputerStoreDatabaseImplement/Models/PC.cs @@ -45,6 +45,8 @@ namespace ComputerStoreDatabaseImplement.Models Name = model.Name, Price = model.Price, EmployeeID = model.EmployeeID, + Employee = context.Employees.First(x => x.ID == model.EmployeeID), + Request = context.Requests.First(x => x.ID == model.RequestID), RequestID = model.RequestID, PCComponents = model.PCComponents }; @@ -56,7 +58,7 @@ namespace ComputerStoreDatabaseImplement.Models { rc.PCID = model.ID; } - + context.SaveChanges(); } diff --git a/ComputerStoreRestAPI/Program.cs b/ComputerStoreRestAPI/Program.cs index 5e1826a..182e025 100644 --- a/ComputerStoreRestAPI/Program.cs +++ b/ComputerStoreRestAPI/Program.cs @@ -1,5 +1,7 @@ using ComputerStoreBusinessLogic.BusinessLogic; using ComputerStoreBusinessLogic.MailStuff; +using ComputerStoreBusinessLogic.OfficePackage; +using ComputerStoreBusinessLogic.OfficePackage.Implements; using ComputerStoreContracts.BindingModels; using ComputerStoreContracts.BusinessLogicContracts; using ComputerStoreContracts.StorageContracts; @@ -29,6 +31,9 @@ builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddSingleton(); builder.Services.AddControllers().AddNewtonsoftJson(x => x.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore); @@ -37,6 +42,9 @@ builder.Services.AddControllers().AddNewtonsoftJson(x => x.SerializerSettings.Re builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); + + + var app = builder.Build(); var mailSender = app.Services.GetService();