diff --git a/FurnitureAssembly/FurnitureAssemblyRestApi/Controllers/OrderInfoController.cs b/FurnitureAssembly/FurnitureAssemblyRestApi/Controllers/OrderInfoController.cs index 7e32c4a..4cff26f 100644 --- a/FurnitureAssembly/FurnitureAssemblyRestApi/Controllers/OrderInfoController.cs +++ b/FurnitureAssembly/FurnitureAssemblyRestApi/Controllers/OrderInfoController.cs @@ -4,7 +4,9 @@ using FurnitureAssemblyContracts.BusinessLogicContracts; using FurnitureAssemblyContracts.SearchModels; using FurnitureAssemblyContracts.ViewModels; using FurnitureAssemblyDatabaseImplement.Models; +using FurnitureAssemblyDataModels.Enums; using Microsoft.AspNetCore.Mvc; +using Org.BouncyCastle.Asn1.X9; using System.Collections.Generic; namespace FurnitureAssemblyRestApi.Controllers @@ -110,6 +112,78 @@ namespace FurnitureAssemblyRestApi.Controllers throw; } } + [HttpGet] + public List>? GetGraphicOrdersByPreviousDay() + { + try + { + List> list = new List>(); + var orderInfos = _orderInfo.ReadList(new OrderInfoSearchModel + { + DateFrom = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day - 1, 0, 0, 0), + DateTo = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day - 1, 23, 59, 59) + }); + foreach (var orderInfo in orderInfos) + { + list.Add(new Tuple(orderInfo.Id.ToString(), orderInfo.Sum)); + } + return list; + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка заказов по времени}"); + throw; + } + } + [HttpGet] + public List>? GetGraphicOrdersByPaymentType() + { + try + { + List<(PaymentType, double)> list = new List<(PaymentType, double)>(); + list.Add((PaymentType.Наличными, 0)); + list.Add((PaymentType.Картой, 0)); + list.Add((PaymentType.Смешанный, 0)); + List orderInfos = _orderInfo.ReadList(null); + foreach (var orderInfo in orderInfos) + { + switch (orderInfo.PaymentType) + { + case PaymentType.Наличными: + list[0] = (PaymentType.Наличными, list[0].Item2 + orderInfo.Sum); + break; + case PaymentType.Картой: + list[1] = (PaymentType.Картой, list[1].Item2 + orderInfo.Sum); + break; + case PaymentType.Смешанный: + list[2] = (PaymentType.Смешанный, list[2].Item2 + orderInfo.Sum); + break; + } + } + List> listRes = new List>(); + foreach (var el in list) + { + switch (el.Item1) + { + case PaymentType.Наличными: + listRes.Add(new Tuple("Наличными", el.Item2)); + break; + case PaymentType.Картой: + listRes.Add(new Tuple("Картой", el.Item2)); + break; + case PaymentType.Смешанный: + listRes.Add(new Tuple("Смешанный", el.Item2)); + break; + } + } + return listRes; + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка заказов по времени}"); + throw; + } + } [HttpPost] public OrderInfoViewModel? AddOrderInfo(OrderInfoBindingModel model) { diff --git a/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Controllers/HomeController.cs b/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Controllers/HomeController.cs index 234229f..fc94bc2 100644 --- a/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Controllers/HomeController.cs +++ b/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Controllers/HomeController.cs @@ -759,5 +759,41 @@ namespace FurnitureAssemblyWorkerClientApp.Controllers } return APIClient.GetRequest>>($"api/orderinfo/getgraphicusersbypreviousmonth"); } + [HttpGet] + public IActionResult GraphicOrdersByPaymentType() + { + if (APIClient.User == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + return View(); + } + [HttpGet] + public List> GetGraphicOrdersByPaymentType() + { + if (APIClient.User == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + return APIClient.GetRequest>>($"api/orderinfo/getgraphicordersbypaymenttype") ; + } + [HttpGet] + public IActionResult GraphicOrdersByPreviousDay() + { + if (APIClient.User == null) + { + return Redirect("~/Home/Enter"); + } + return View(); + } + [HttpGet] + public List> GetGraphicOrdersByPreviousDay() + { + if (APIClient.User == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + return APIClient.GetRequest>>($"api/orderinfo/GetGraphicOrdersByPreviousDay"); + } } } \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Views/Home/GraphicOrdersByPaymentType.cshtml b/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Views/Home/GraphicOrdersByPaymentType.cshtml new file mode 100644 index 0000000..f5118cd --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Views/Home/GraphicOrdersByPaymentType.cshtml @@ -0,0 +1,117 @@ +@using FurnitureAssemblyContracts.ViewModels + +@{ + ViewData["Title"] = "График по типам оплаты"; +} + +
+ @{ +

График по типам оплаты

+ +
+
+ } +
+ +@section Scripts { + +} \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Views/Home/GraphicOrdersByPreviousDay.cshtml b/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Views/Home/GraphicOrdersByPreviousDay.cshtml new file mode 100644 index 0000000..5299d72 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Views/Home/GraphicOrdersByPreviousDay.cshtml @@ -0,0 +1,117 @@ +@using FurnitureAssemblyContracts.ViewModels + +@{ + ViewData["Title"] = "График продаж за предыдущий день"; +} + +
+ @{ +

График продаж за предыдущий день

+ +
+
+ } +
+ +@section Scripts { + +} \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Views/Home/Graphics.cshtml b/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Views/Home/Graphics.cshtml index b004b25..09755df 100644 --- a/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Views/Home/Graphics.cshtml +++ b/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Views/Home/Graphics.cshtml @@ -14,6 +14,8 @@ } \ No newline at end of file