コード例 #1
0
        public ActionResult Create(Measurement measurement)
        {
            if (ModelState.IsValid)
            {
                db.Measurements.Add(measurement);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.UserId = new SelectList(db.Users, "UserId", "Username", measurement.UserId);
            return View(measurement);
        }
コード例 #2
0
 public ActionResult Edit(Measurement measurement)
 {
     if (ModelState.IsValid)
     {
         db.Entry(measurement).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.UserId = new SelectList(db.Users, "UserId", "Username", measurement.UserId);
     return View(measurement);
 }