// GET: Earnings public ActionResult Index() { var earningVm = new EarningViewModel(); earningVm.ListOfEarnings = _earningsRepository.GetWhereWithIncludes(x => x.Id > 0, x => x.BankAccount, x => x.SubCategory, x => x.Category).ToList(); return(View(earningVm)); }
public ActionResult Edit(EarningViewModel earningVm) { if (ModelState.IsValid) { _earningsRepository.Update(earningVm.Earning); _bankAccountLogic.CalculateBalanceOfAllAccounts(); return(RedirectToAction("Index")); } earningVm = CreateVmWithLists(); return(View(earningVm)); }
private EarningViewModel CreateVmWithLists() { var earningVm = new EarningViewModel(); var bankAccounts = _bankAccountRepository.GetWhere(x => x.Id > 0).ToList(); var categories = _categoriesRepository.GetWhere(x => x.Id > 0).ToList(); var subCategories = _subCategoriesRepository.GetWhere(x => x.Id > 0).ToList(); earningVm.SelectListOfBankAccounts = new SelectList(bankAccounts, "Id", "AccountName"); earningVm.SelectListOfEarningCategories = new SelectList(categories, "Id", "CategoryName"); earningVm.SelectListOfEarningSubCategories = new SelectList(subCategories, "Id", "SubCategoryName"); return(earningVm); }
public ActionResult DeleteConfirmed(int id) { var earningVm = new EarningViewModel(); earningVm.Earning = _earningsRepository.GetWhereWithIncludes(e => e.Id == id, x => x.BankAccount, x => x.SubCategory, x => x.Category).FirstOrDefault(); if (earningVm.Earning == null) { return(HttpNotFound()); } _earningsRepository.Delete(earningVm.Earning); _bankAccountLogic.CalculateBalanceOfAllAccounts(); return(RedirectToAction("Index")); }
// GET: Earnings/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var earningVm = new EarningViewModel(); earningVm.Earning = _earningsRepository.GetWhereWithIncludes(e => e.Id == id, x => x.BankAccount, x => x.SubCategory, x => x.Category).FirstOrDefault(); if (earningVm.Earning == null) { return(HttpNotFound()); } return(View(earningVm)); }
// GET: Earnings/Create public ActionResult Create() { EarningViewModel earningVm = CreateVmWithLists(); return(View(earningVm)); }