public ActionResult Create(Sessions sessions) { if (ModelState.IsValid) { try { sessions.ID = Guid.NewGuid(); sessions.PID = Guid.Parse(Request["PracticesID"]); // sessions.sessionColor.FirstOrDefault().Color = "#fff"; db.Sessions.Add(sessions); db.SaveChanges(); return Content(Boolean.TrueString); } catch(Exception ex) { ModelState.AddModelError("_Form", ex.Message); ViewBag.PracticesID = new SelectList(db.Practices, "ID", "Name", sessions.PID); return View(sessions); } } ViewBag.PracticesID = new SelectList(db.Practices, "ID", "Name", sessions.PID); return View(sessions); }
public ActionResult Edit(Sessions sessions) { if (ModelState.IsValid) { db.Entry(sessions).State = EntityState.Modified; db.SaveChanges(); return Content(Boolean.TrueString); } ViewBag.PracticesID = new SelectList(db.Practices, "ID", "Name", sessions.PID); return View(sessions); }