public ActionResult EditView(opr.Models.Section model) { Models.oprEntities dbs = new oprEntities(); var mod = dbs.DefTables.Select(s => new { s.TableId, s.TableName }).ToList(); SelectList selectList = new SelectList(mod, "TableName", "TableName"); ViewBag.dataForDropDown = selectList; var mods = dbs.DefControls.Select(c => new { c.ControId, c.ControlName }).ToList(); SelectList selectLists = new SelectList(mods, "ControlName", "ControlName"); ViewBag.dataForDropDowns = selectLists; Models.oprEntities db = new oprEntities(); db.Entry(model).State = System.Data.Entity.EntityState.Modified; try { db.SaveChanges(); return(RedirectToAction("SectionDetail")); } catch { } ModelState.AddModelError("", "Unable to save changes"); return(View(model)); }
public ActionResult Index(opr.Models.Section model) { model.IsDeleted = true; model.IsActive = true; opr.Models.oprEntities db = new oprEntities(); db.Sections.Add(model); db.SaveChanges(); return(View(new Section())); }
public ActionResult DeleteData(opr.Models.Section model) { Models.oprEntities db = new oprEntities(); db.Entry(model).State = System.Data.Entity.EntityState.Modified; try { db.SaveChanges(); return(RedirectToAction("SectionDetail")); } catch { } ModelState.AddModelError("", "Unable to save changes"); return(View(model)); }
public ActionResult Index(opr.Models.Section model) { Models.oprEntities dbs = new oprEntities(); var mod = dbs.DefTables.Select(s => new { s.TableId, s.TableName }).ToList(); SelectList selectList = new SelectList(mod, "TableName", "TableName"); ViewBag.dataForDropDown = selectList; var mods = dbs.DefControls.Select(c => new { c.ControId, c.ControlName }).ToList(); SelectList selectLists = new SelectList(mods, "ControlName", "ControlName"); ViewBag.dataForDropDowns = selectLists; model.IsDeleted = true; model.IsActive = true; opr.Models.oprEntities db = new oprEntities(); try { db.Sections.Add(model); db.SaveChanges(); } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { foreach (var entityValidationErrors in ex.EntityValidationErrors) { foreach (var validationError in entityValidationErrors.ValidationErrors) { Response.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage); } } } return(View(new Section())); }