Report logis запрос нв получение данных из бд

This commit is contained in:
Илья Федотов 2024-04-29 19:33:15 +04:00
parent d934652b6c
commit d07ef5499f
5 changed files with 91 additions and 1 deletions

View File

@ -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<ReportOrdersViewModel> GetOrders(ReportBindingModel model) {
throw new NotImplementedException();
}
// Получение списка заказов за определенный период
public List<ReportOrdersViewModel> 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();
}
}
}

View File

@ -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; }
}
}

View File

@ -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<ReportOrdersViewModel> GetOrders(ReportBindingModel model);
}
}

View File

@ -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;
}
}

View File

@ -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]