public ActionResult TimeRange(TimeRangeReportViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var newmodel = GetModelForTimeRange(model.DateFrom, model.DateTo); return(View(newmodel)); }
private TimeRangeReportViewModel GetModelForTimeRange(DateTime dateFrom, DateTime dateTo) { var finanses = _unitOfWork.FinanceRepository.GetOverview(x => x.TimeEvent >= dateFrom && x.TimeEvent <= dateTo).ToList(); var model = new TimeRangeReportViewModel() { DateFrom = dateFrom, DateTo = dateTo, AnyCashOperation = false, Categories = _unitOfWork.CategoryRepository.GetOverview().ToList() }; if (finanses.Any()) { model.Revenues = Mapper.Map <List <RevenueViewModel> >(finanses.Where(x => !x.Category.IsExpense).ToList()); model.Expenses = Mapper.Map <List <RevenueViewModel> >(finanses.Where(x => x.Category.IsExpense).ToList()); model.AnyCashOperation = true; } ModelState.Clear(); ModelState.Remove("DateFrom"); ModelState.Remove("DateTo"); return(model); }