diff --git a/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportLogic.cs b/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportLogic.cs new file mode 100644 index 0000000..153b274 --- /dev/null +++ b/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportLogic.cs @@ -0,0 +1,42 @@ +using ElectronicsShopContracts.BindingModels; +using ElectronicsShopContracts.BusinessLogicContracts; +using ElectronicsShopContracts.SearchModels; +using ElectronicsShopContracts.StorageContracts; +using ElectronicsShopContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ElectronicsShopBusinessLogic.BusinessLogic +{ + public class ReportLogic : IReportLogic + { + private readonly IOrderStorage _orderStorage; + private readonly IProductStorage _productStorag; + + public ReportLogic(IOrderStorage orderStorage, IProductStorage productStorag) { + _orderStorage = orderStorage; + _productStorag = productStorag; + } + + public List GetOrders(ReportBindingModel model) { + throw new NotImplementedException(); + } + + // Получение списка заказов за определенный период + public List GerOrders(ReportBindingModel model) { + return _orderStorage.GetFilteredList(new OrderSearchModel { + DateFrom = model.DateFrom, + DateTo = model.DateTo, + }).Select(x => new ReportOrdersViewModel { + ID = x.ID, + DateCreate = x.DateCreate, + Sum = x.Sum, + PaymeantOption = x.PaymeantOption.ToString(), + OrderStatus = x.Status.ToString(), + }).ToList(); + } + } +} diff --git a/ElectronicsShop/ElectronicsShopContracts/BindingModels/ReportBindingModel.cs b/ElectronicsShop/ElectronicsShopContracts/BindingModels/ReportBindingModel.cs new file mode 100644 index 0000000..87da266 --- /dev/null +++ b/ElectronicsShop/ElectronicsShopContracts/BindingModels/ReportBindingModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ElectronicsShopContracts.BindingModels +{ + public class ReportBindingModel + { + public string FileName { get; set; } = string.Empty; + public DateTime? DateFrom { get; set; } + public DateTime? DateTo { get; set; } + } +} diff --git a/ElectronicsShop/ElectronicsShopContracts/BusinessLogicContracts/IReportLogic.cs b/ElectronicsShop/ElectronicsShopContracts/BusinessLogicContracts/IReportLogic.cs new file mode 100644 index 0000000..c907c68 --- /dev/null +++ b/ElectronicsShop/ElectronicsShopContracts/BusinessLogicContracts/IReportLogic.cs @@ -0,0 +1,16 @@ +using ElectronicsShopContracts.BindingModels; +using ElectronicsShopContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ElectronicsShopContracts.BusinessLogicContracts +{ + public interface IReportLogic + { + // Получение списка заказов за определенный период + List GetOrders(ReportBindingModel model); + } +} diff --git a/ElectronicsShop/ElectronicsShopContracts/ViewModels/ReportOrdersViewModel.cs b/ElectronicsShop/ElectronicsShopContracts/ViewModels/ReportOrdersViewModel.cs new file mode 100644 index 0000000..0052dda --- /dev/null +++ b/ElectronicsShop/ElectronicsShopContracts/ViewModels/ReportOrdersViewModel.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ElectronicsShopContracts.ViewModels +{ + public class ReportOrdersViewModel + { + public int ID { get; set; } + public DateTime DateCreate { get; set; } + public double Sum { get; set; } + public string PaymeantOption { get; set; } = string.Empty; + public string OrderStatus { get; set; } = string.Empty; + } +} diff --git a/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/Order.cs b/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/Order.cs index f0e7733..3495357 100644 --- a/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/Order.cs +++ b/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/Order.cs @@ -23,7 +23,7 @@ namespace ElectronicsShopDataBaseImplement.Models [Required] public PaymeantOption PaymeantOption { get; set; } = PaymeantOption.Неизвестно; [Required] - public DateTime DateCreate { get; set; }= DateTime.Now; + public DateTime DateCreate { get; set; } = DateTime.Now; [Required] public DateTime? DateImplement { get; set; } [Required]