コード例 #1
0
 public ActionResult Create(ObservationViewModel vm)
 {
     if (ModelState.IsValid)
     {
         vm.Initialise(db);
         vm.PrepareSave();
         db.Observations.Add(vm.Model);
         db.SaveChanges();
         return RedirectToAction("edit", "VisitHistories", new { id = vm.Model.VisitHistoryId }).AddFragment("ObservationsSection");
     }
     vm.ObservableEntitySelectList = new SelectList(db.ObservableEntities, "ObservableEntityID", "Name");
     return View(vm);
 }
コード例 #2
0
 public ActionResult Edit(ObservationViewModel vm)
 {
     if (ModelState.IsValid)
     {
         var item = db.Entry(vm.Model);
         item.State = EntityState.Modified;
         vm.Initialise(db);
         vm.PrepareSave();
         db.SaveChanges();
         return RedirectToAction("edit", "VisitHistories", new { id = vm.Model.VisitHistoryId }).AddFragment("ObservationSection");
     }
     vm.PopulateSelectLists();
     return View(vm);
 }