Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
 public IActionResult GetRevenue([FromQuery] GetSalesPerDayRequest request)
 {
     return(Ok(_salesService.GetRevenuePerDay(request)));
 }
Example #4
0
 public IActionResult GetTotalNumber([FromQuery] GetSalesPerDayRequest request)
 {
     return(Ok(_salesService.GetSalesByDate(request)));
 }