public ActionResult DeleteConfirmed(int id) { FloorTemplate floor = context.Floors.Single(x => x.ID == id); context.Floors.Remove(floor); context.SaveChanges(); return(RedirectToAction("Edit", "Plans", new { id = floor.PlanID })); }
public ActionResult Edit(FloorTemplate floor) { if (ModelState.IsValid) { context.Entry(floor).State = EntityState.Modified; context.SaveChanges(); return(RedirectToAction("Index")); } return(View(floor)); }
public ActionResult Create(FloorTemplate floor) { if (ModelState.IsValid) { context.Floors.Add(floor); context.SaveChanges(); return(RedirectToAction("Edit", new { id = floor.ID })); } return(View(floor)); }
public ActionResult CreateBlank(int planId) { using (var dtx = new HeimContext()) { int?floorNumber = dtx.Floors.Where(f => f.PlanID == planId).Max(f => (int?)f.FloorNumber); var floor = new FloorTemplate { PlanID = planId, FloorNumber = floorNumber.HasValue? +floorNumber.Value + 1: 1 }; dtx.Floors.Add(floor); dtx.SaveChanges(); return(RedirectToAction("Edit", new { id = floor.ID })); } }
// // GET: /Floors/Details/5 public ViewResult Details(int id) { FloorTemplate floor = context.Floors.Single(x => x.ID == id); return(View(floor)); }