public IActionResult GetOrdersNumber() { OrderNumberViewModel model = new OrderNumberViewModel(); model.End = DateTime.Now; model.Start = new DateTime(2021, 02, 10); return(View(model)); }
public IActionResult GetOrdersNumber([Bind("Start,End")] OrderNumberViewModel model) { var total = _db.Orders .Where(o => o.Date >= model.Start && o.Date <= model.End) .Sum(o => o.TotalPrice); var count = _db.Orders .Count(o => o.Date >= model.Start && o.Date <= model.End); model.Number = count; model.TotalSum = total; return(View(model)); }