public ActionResult Edit(int id) { var userID = Guid.Parse(User.Identity.GetUserId()); var serviceTwo = new GoalItemService(userID); var modelTwo = serviceTwo.GetGoalItem().ToList(); modelTwo.Insert(0, new GoalItemListItem { GoalItemID = null, GoalItemName = "No Goal" }); ViewBag.GoalItem = modelTwo; var service = CreateMonthlyFinanceService(); var detail = service.GetMonthlyFinanceByID(id); var model = new MonthlyFinanceEdit { MonthlyTakeHome = detail.MonthlyTakeHome, CostOfBills = detail.CostOfBills, GoalItemID = detail.GoalItemID, MonthlyFinanceID = detail.MonthlyFinanceID, Month = detail.Month, Year = detail.Year }; return(View(model)); }
public ActionResult Edit(int id, MonthlyFinanceEdit model) { var userID = Guid.Parse(User.Identity.GetUserId()); var serviceTwo = new GoalItemService(userID); var modelTwo = serviceTwo.GetGoalItem(); ViewBag.GoalItem = modelTwo; if (!ModelState.IsValid) { return(View(model)); } if (model.MonthlyFinanceID != id) { ModelState.AddModelError("", "Id Mismatch"); return(View(model)); } var service = CreateMonthlyFinanceService(); if (service.UpdateMonthlyFinance(model)) { TempData["SaveResult"] = "Your month was updated."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Your month could not be updated."); return(View(model)); }
private GoalItemService CreateGoalItemService() { var userID = Guid.Parse(User.Identity.GetUserId()); var service = new GoalItemService(userID); return(service); }
public ActionResult Edit(int id) { var userID = Guid.Parse(User.Identity.GetUserId()); var serviceTwo = new GoalItemService(userID); var modelTwo = serviceTwo.GetGoalItem().ToList(); modelTwo.Insert(0, new GoalItemListItem { GoalItemID = null, GoalItemName = "No Goal" }); ViewBag.GoalItem = modelTwo; var service = CreateNoBuyService(); var detail = service.GetNoBuyByID(id); var model = new NoBuyEdit { ItemID = detail.ItemID, ItemName = detail.ItemName, ItemPrice = detail.ItemPrice, ItemLocation = detail.ItemLocation, GoalItemID = detail.GoalItemID }; return(View(model)); }
public ActionResult Index() { var userID = Guid.Parse(User.Identity.GetUserId()); var service = new GoalItemService(userID); var model = service.GetGoalItem(); var noBuyService = new NoBuyService(userID); var noBuyTotal = noBuyService.GetNoBuys().Sum(e => e.ItemPrice); ViewBag.TotalSaved = noBuyTotal; return(View(model)); }
public ActionResult Create() { var userID = Guid.Parse(User.Identity.GetUserId()); var service = new GoalItemService(userID); var model = service.GetGoalItem().ToList(); model.Insert(0, new GoalItemListItem { GoalItemID = null, GoalItemName = "No Goal" }); ViewBag.GoalItem = model; return(View()); }