Exemple #1
0
        public ActionResult TimeRange(TimeRangeReportViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var newmodel = GetModelForTimeRange(model.DateFrom, model.DateTo);

            return(View(newmodel));
        }
Exemple #2
0
        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);
        }