public List <GetNumberByDayResponse> GetSalesByDate(GetSalesPerDayRequest request) { List <GetNumberByDayResponse> response = _context.SaleItems.Include(y => y.Sale) .Where(x => x.Sale.Date >= request.dateFrom && x.Sale.Date <= request.dateTo) .GroupBy(x => x.Sale.Date) .Select(t => new GetNumberByDayResponse { Date = t.Key.ToShortDateString(), TotalNumber = t.Sum(x => x.Quantity) }).ToList(); return(response); }
public List <GetSalesRevenuePerDayResponse> GetRevenuePerDay(GetSalesPerDayRequest request) { List <GetSalesRevenuePerDayResponse> response = _context.SaleItems .Include(y => y.Sale) .Include(x => x.Article) .Where(x => x.Sale.Date >= request.dateFrom && x.Sale.Date <= request.dateTo) .Select(t => new GetSalesRevenuePerDayResponse { Date = t.Sale.Date.ToShortDateString(), TotalRevenue = (t.Quantity * t.Article.SalesPrice) }).ToList().GroupBy(x => x.Date).Select(a => new GetSalesRevenuePerDayResponse { Date = a.Key, TotalRevenue = a.Sum(x => x.TotalRevenue) }).ToList(); // com return(response); }
public IActionResult GetRevenue([FromQuery] GetSalesPerDayRequest request) { return(Ok(_salesService.GetRevenuePerDay(request))); }
public IActionResult GetTotalNumber([FromQuery] GetSalesPerDayRequest request) { return(Ok(_salesService.GetSalesByDate(request))); }