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); }
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); }