コード例 #1
0
 public IActionResult DateReport(DateTime fromDate, DateTime toDate)
 {
     if (User.Identity.Name == null)
     {
         return(RedirectToAction("Index", "NotFound"));
     }
     else
     {
         DateReportViewModel viewModel = new DateReportViewModel();
         viewModel.Orders = new List <Order>();
         if (fromDate == DateTime.MinValue)
         {
             viewModel.FromDate = new DateTime(DateTime.Now.Year, 1, 1);
             viewModel.ToDate   = new DateTime(DateTime.Now.Year, 12, 31);
             viewModel.Orders.AddRange(ordersService.GetOrders());
             return(View(viewModel));
         }
         else
         {
             viewModel.Orders.AddRange(ordersService.GetOrders().Where(o => o.Date >= fromDate && o.Date <= toDate));
             viewModel.FromDate = fromDate;
             viewModel.ToDate   = toDate;
             return(View(viewModel));
         }
     }
 }
コード例 #2
0
 public IActionResult DateReport(DateReportViewModel vm)
 {
     return(RedirectToAction("DateReport", "Report", new { fromDate = vm.FromDate, toDate = vm.ToDate }));
 }