public ActionResult Create(FormCollection formCollection) { if (Session["Email"] != null) { Rotation rotations = new Rotation(); RotationContext context = new RotationContext(); rotations.Rotations = formCollection["Rotations"]; rotations.Supervisor = formCollection["Supervisor"]; context.Rotations.Add(rotations); context.SaveChanges(); return(RedirectToAction("Index")); } return(RedirectToAction("Index", "Home")); }
public ActionResult Delete(int?id, FormCollection formCollection) { if (Session["Email"] != null) { if (id != null) { RotationContext context = new RotationContext(); Rotation rotations = context.Rotations.Single(pro => pro.Id == id); context.Rotations.Remove(rotations); context.SaveChanges(); return(RedirectToAction("Index")); } else { return(RedirectToAction("Index", "Rotation")); } } return(RedirectToAction("Index", "Home")); }
public ActionResult Edit(FormCollection formCollection, int?id) { if (Session["Email"] != null) { if (id != null) { RotationContext context = new RotationContext(); Rotation rotation = context.Rotations.Single(pro => pro.Id == id); rotation.Rotations = formCollection["Rotations"]; rotation.Supervisor = formCollection["Supervisor"]; context.SaveChanges(); return(RedirectToAction("Index")); } else { return(RedirectToAction("Index", "Rotation")); } } return(RedirectToAction("Index", "Home")); }