//PUT /chores/edit/{id} public async Task <ActionResult> Edit(int id) { ChoresList item = await context.Chorelist.FindAsync(id); if (item == null) { return(NotFound("Chore not found")); } return(View(item)); }
public async Task <ActionResult> Edit(ChoresList item) { //check to see if model is valid. if (ModelState.IsValid) { context.Update(item); await context.SaveChangesAsync(); TempData["Success"] = "Chore has been updated!"; //send the back to home page if successfully added to list. return(RedirectToAction("Index")); } return(View(item)); }
public async Task <ActionResult> Create(ChoresList item) { //check to see if model is valid. if (ModelState.IsValid) { var user = User.Identity.Name; item.listOwner = user; context.Add(item); await context.SaveChangesAsync(); TempData["Success"] = "Chore has been added to list!"; //send the back to home page if successfully added to list. return(RedirectToAction("Index")); } return(View(item)); }
public async Task <ActionResult> Delete(int id) { ChoresList item = await context.Chorelist.FindAsync(id); if (item == null) { TempData["Error"] = "The chore does not exist!"; } else { context.Chorelist.Remove(item); await context.SaveChangesAsync(); TempData["Success"] = "Chore has been deleted!"; } return(RedirectToAction("Index")); }