Example #1
0
        public ActionResult Create(FloorTemplate floor)
        {
            if(ModelState.IsValid) {
                context.Floors.Add(floor);
                context.SaveChanges();

                return RedirectToAction("Edit", new { id = floor.ID });
            }

            return View(floor);
        }
Example #2
0
        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 });
            }
        }
Example #3
0
 public ActionResult Edit(FloorTemplate floor)
 {
     if(ModelState.IsValid) {
         context.Entry(floor).State = EntityState.Modified;
         context.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(floor);
 }