// GET: Expenses public ActionResult Index() { var expenseVm = new ExpenseViewModel(); expenseVm.ListOfExpenses = _expenseRepository.GetWhereWithIncludes(e => e.Id > 0, x => x.BankAccount, x => x.SubCategory, x => x.Category).ToList(); return(View(expenseVm)); }
public ActionResult Details(FinancialOperationsHistoryViewModel model) { model.ListofFinancialOperation = new List <FinancialOperation>(); var listOfExpenses = _expensesRepository .GetWhereWithIncludes(t => t.BankAccountId == model.FinancialOperation.BankAccountId, e => e.Category, e => e.SubCategory, e => e.BankAccount); listOfExpenses.ForEach(exp => exp.AmountOfMoney *= (-1)); listOfExpenses.ForEach(exp => exp.DescriptionOfOperation = @"Category: " + exp.Category.CategoryName + "<br/>" + " SubCategory: " + exp.SubCategory.SubCategoryName); var listOfEarnings = _earningsRepository.GetWhereWithIncludes(t => t.BankAccountId == model.FinancialOperation.BankAccountId, e => e.Category, e => e.SubCategory, e => e.BankAccount); listOfEarnings.ForEach(earn => earn.DescriptionOfOperation = @"Category: " + earn.Category.CategoryName + "<br/>" + " SubCategory: " + earn.SubCategory.SubCategoryName); var listOfTransferIncomes = _transferRepository.GetWhereWithIncludes(t => t.TargetBankAccountId == model.FinancialOperation.BankAccountId, e => e.SourceBankAccount, e => e.TargetBankAccount); listOfTransferIncomes.ForEach(transfer => { transfer.DescriptionOfOperation = transfer.SourceBankAccount.AccountName; transfer.BankAccount = transfer.TargetBankAccount; }); var listOfTransferOutcomes = _transferRepository.GetWhereWithIncludes(t => t.SourceBankAccountId == model.FinancialOperation.BankAccountId, e => e.SourceBankAccount, e => e.TargetBankAccount); listOfTransferOutcomes.ForEach(transf => { transf.AmountOfMoney *= (-1); transf.DescriptionOfOperation = transf.TargetBankAccount.AccountName; transf.BankAccount = transf.SourceBankAccount; }); model.ListofFinancialOperation.AddRange(listOfEarnings); model.ListofFinancialOperation.AddRange(listOfExpenses); model.ListofFinancialOperation.AddRange(listOfTransferOutcomes); model.ListofFinancialOperation.AddRange(listOfTransferIncomes); return(View(model)); }