From 82308fd351c3de44deb050418188e20c4380c2f3 Mon Sep 17 00:00:00 2001 From: devil_1nc Date: Tue, 30 Jul 2024 18:41:27 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9A=D1=83=D1=80=D1=81=D0=B0=D1=87:=20=D0=92?= =?UTF-8?q?=D0=BE=D0=B9=D0=BD=D0=B0=20=D0=91=D0=B5=D1=81=D0=BA=D0=BE=D0=BD?= =?UTF-8?q?=D0=B5=D1=87=D0=BD=D0=BE=D1=81=D1=82=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implements/PurchaseStorage.cs | 3 ++- RestAPI/Controllers/PurchaseController.cs | 23 +++++++++++++++++++ RestAPI/Program.cs | 1 + RestAPI/RestAPI.csproj | 1 + WebApp/Pages/User/Purchases.cshtml | 1 + WebApp/Pages/User/Purchases.cshtml.cs | 22 +++++++++--------- WebApp/WebApp.csproj | 1 + 7 files changed, 40 insertions(+), 12 deletions(-) diff --git a/DatabaseImplement/Implements/PurchaseStorage.cs b/DatabaseImplement/Implements/PurchaseStorage.cs index ae2e23c..5fc14cb 100644 --- a/DatabaseImplement/Implements/PurchaseStorage.cs +++ b/DatabaseImplement/Implements/PurchaseStorage.cs @@ -127,9 +127,10 @@ namespace DatabaseImplement.Implements var cartItems = context.CartItems - .Where(x => x.PurchaseId == model.Id).ToList() + .Where(x => x.PurchaseId == purchase.Id).ToList() .Select(x => x.GetViewModel).ToList(); + var products = new List(); foreach (var item in cartItems) diff --git a/RestAPI/Controllers/PurchaseController.cs b/RestAPI/Controllers/PurchaseController.cs index 81bf079..a3de331 100644 --- a/RestAPI/Controllers/PurchaseController.cs +++ b/RestAPI/Controllers/PurchaseController.cs @@ -9,6 +9,8 @@ using DataModels.Models; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using MigraDoc.DocumentObjectModel; +using MigraDoc.Rendering; namespace RestAPI.Controllers { @@ -132,5 +134,26 @@ namespace RestAPI.Controllers return null; } } + [HttpGet] + public byte[] CreateChart(Guid userId) + { + Document document = new Document(); + Section section = document.AddSection(); + + section.AddParagraph("Столбчатая диаграмма"); + + using (MemoryStream stream = new MemoryStream()) + { + PdfDocumentRenderer renderer = new PdfDocumentRenderer(true, PdfSharp.Pdf.PdfFontEmbedding.Always); + renderer.Document = document; + renderer.RenderDocument(); + + // Сохранение документа в MemoryStream + renderer.PdfDocument.Save(stream, false); + + // Получение массива байтов из MemoryStream + return stream.ToArray(); + } + } } } diff --git a/RestAPI/Program.cs b/RestAPI/Program.cs index a1747ab..d002bbb 100644 --- a/RestAPI/Program.cs +++ b/RestAPI/Program.cs @@ -88,5 +88,6 @@ app.UseHttpsRedirection(); app.UseAuthorization(); app.MapControllers(); +app.UseDeveloperExceptionPage(); app.Run(); \ No newline at end of file diff --git a/RestAPI/RestAPI.csproj b/RestAPI/RestAPI.csproj index ee6f069..8dd6c3a 100644 --- a/RestAPI/RestAPI.csproj +++ b/RestAPI/RestAPI.csproj @@ -12,6 +12,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/WebApp/Pages/User/Purchases.cshtml b/WebApp/Pages/User/Purchases.cshtml index 884784c..d345165 100644 --- a/WebApp/Pages/User/Purchases.cshtml +++ b/WebApp/Pages/User/Purchases.cshtml @@ -29,6 +29,7 @@ } else { + Статистика