public ActionResult Show(long accountId, DateTime startDate, DateTime endDate) { var allStatistics = new StationStatisticsViewModel(); // The statistics for all the clients if (accountId == AllStationAccountId) { var accounts = context.StationAccounts; allStatistics.StationAccountId = StationStatisticsController.AllStationAccountId; allStatistics.StationAccountName = StationStatisticsController.AllStationAccountName; allStatistics.StartDate = startDate; allStatistics.EndDate = endDate; foreach (var account in accounts) { var statistics = GetStationStatistics(startDate, endDate, account); allStatistics.TotalIncompleteQuantity += statistics.TotalIncompleteQuantity; allStatistics.TotalIncreasedBalance += statistics.TotalIncreasedBalance; allStatistics.TotalIncreasedLoan += statistics.TotalIncreasedLoan; allStatistics.TotalIncreasedSubscriptionAmount += statistics.TotalIncreasedSubscriptionAmount; allStatistics.TotalPaidAmount += statistics.TotalPaidAmount; allStatistics.TotalQuantity += statistics.TotalQuantity; } } else { var account = context.StationAccounts.Find(accountId); allStatistics = GetStationStatistics(startDate, endDate, account); } return(View(allStatistics)); }
// GET: ClientStatistics public ActionResult Query() { var accounts = context.StationAccounts; var stationOptions = new SelectList( accounts.Select( n => new SelectListItem() { Selected = false, Text = n.StationName, Value = n.StationAccountId.ToString() }).ToList().Concat(new List <SelectListItem>() { new SelectListItem() { Text = AllStationAccountName, Value = AllStationAccountId.ToString() } }), "Value", "Text", 0); var model = new StationStatisticsViewModel() { StationAccountList = stationOptions }; return(View(model)); }
public ActionResult Query([Bind(Include = "StationAccountId, StartDate, EndDate")] StationStatisticsViewModel stationStatistics) { if (ModelState.IsValid) { return(RedirectToAction( "Show", new { accountId = stationStatistics.StationAccountId, startDate = stationStatistics.StartDate, endDate = stationStatistics.EndDate })); } else { throw new InvalidOperationException("非法请求"); } }