// // GET: /ServiceCheckLists/Create public ActionResult Create(Guid?sclId = null) { var model = new SCheckList() { EntitySCL = sclId == null ? new ServiceCheckList() : SessionData.CurrentSession.ServiceCheckListList.FirstOrDefault(p => p.Id == sclId), CheckListCatories = new SelectList(SessionData.CurrentSession.CheckListCategoryList.ToList(), "Id", "Name") }; return(View("CreateEdit", model)); }
public ActionResult CreateEdit(SCheckList model) { // TODO: Add insert logic here using (var db = new SCMSEntities()) { if (model.EntitySCL.Id.Equals(Guid.Empty)) { model.EntitySCL.Id = Guid.NewGuid(); db.ServiceCheckLists.Add(model.EntitySCL); } else { db.ServiceCheckLists.Attach(model.EntitySCL); ((IObjectContextAdapter)db).ObjectContext.ObjectStateManager.ChangeObjectState(model.EntitySCL, System.Data.EntityState.Modified); } db.SaveChanges(); } SessionData.CurrentSession.ServiceCheckListList = null; SessionData.CurrentSession.CheckListCategoryList = null; return(ListView()); }