public BudgetTotalVm GetBudetViewModel() { BudgetTotalVm vm = new BudgetTotalVm(); vm.Scores = _rep.Scores.GetAll(); vm.TotalSum = vm.Scores.Sum(x => x.Balance); vm.TotalSumWithoutCredit = vm.Scores.Where(x => x.ScoreType != ScoreTypes.Credit).Sum(x => x.Balance); vm.TotalCreditDebts = vm.Scores.Where(x => x.ScoreType == ScoreTypes.Credit).Sum(x => x.CreditDebts); vm.MinPayment = vm.Scores.Where(x => x.ScoreType == ScoreTypes.Credit).FirstOrDefault()?.CreditMinPayment; vm.IsMinPaymentSucces = false; vm.PaymentDate = vm.Scores.Where(x => x.ScoreType == ScoreTypes.Credit).FirstOrDefault()?.CreditPaymentDate; return(vm); }
public BudgetTotalVm GetViewModel() { BudgetTotalVm vm = new BudgetTotalVm(); vm.Scores = new Models.ScoreVm.ScoreListVm(); vm.Scores.AllRows = _scoreProvider.GetAll().Select(x => new Models.ScoreVm.ScoreItemVm() { Balance = x.Balance, Name = x.Name, CreditDebts = x.CreditDebts, CreditLimit = x.CreditLimit, OrderId = x.OrderId, ScoreType = new BootstrapSelectVm() { SelectedItemText = x.ScoreType.ToString() } }); vm.Schedule = new Dictionary <DateTime, List <ScheduleItemVm> >(); var collection = _scheduleProvider.GetAll().Select(x => new ScheduleItemVm() { ActionDate = x.ActionDate, Amount = x.Amount, Description = x.Description, ShortName = x.ShortName }).ToList(); var datesCollection = collection.Select(x => x.ActionDate).ToList(); List <DateTime> dates = datesCollection.Distinct().OrderBy(x => x.ToShortDateString()).ToList(); foreach (DateTime date in dates) { List <ScheduleItemVm> list = collection.Where(x => x.ActionDate.ToShortDateString() == date.ToShortDateString()).ToList(); vm.Schedule.Add(date, list); } return(vm); }