public async Task <IActionResult> Edit(SavingsGoal goal) { if (ModelState.IsValid) { _repo.Edit <SavingsGoal>(goal); if (await _repo.SaveAll()) { return(RedirectToAction("Goals")); } } return(View(goal)); }
public async Task <IActionResult> Edit(IFormCollection model) { foreach (var item in model.Keys) { if (item != "__RequestVerificationToken" && item != "BudgetId") { var mapper = new BudgetCategoryMapper() { BudgetId = Guid.Parse(model["BudgetId"].ToString()), CategoryId = Guid.Parse(item.ToString()), Amount = model[item].ToString() == "" ? 0 : float.Parse(model[item].ToString()) }; if (await _repo.BudgetMapExists(mapper.BudgetId, mapper.CategoryId)) { _repo.Edit <BudgetCategoryMapper>(mapper); } else { _repo.Add <BudgetCategoryMapper>(mapper); } } } if (await _repo.SaveAll()) { return(RedirectToAction("Index")); } return(View()); }
public async Task <IActionResult> Edit(Category model) { if (ModelState.IsValid) { _repo.Edit <Category>(model); if (await _repo.SaveAll()) { return(RedirectToAction("Index")); } } return(View()); }
public async Task <IActionResult> Edit(Saving model) { if (ModelState.IsValid) { _repo.Edit <Saving>(model); if (await _repo.SaveAll()) { return(RedirectToAction("Details", "SavingsGoal", new { id = model.SavingsGoalId })); } throw new Exception("Something went wrong trying to edit saving record"); } return(View()); }
public async Task <IActionResult> Edit(ExpenseViewModel model) { if (ModelState.IsValid) { var expense = new Expense(); expense.Id = model.Id; expense.Amount = model.Amount; expense.Description = model.Description; expense.Date = model.Date; expense.CategoryId = model.CategoryId; _repo.Edit <Expense>(expense); if (await _repo.SaveAll()) { return(RedirectToAction("Index")); } } model.Categories = await _repo.GetList <Category>(); return(View(model)); }