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 EditGroup(opr.Models.Group grp) { oprEntities groupData = new oprEntities(); groupData.Entry(grp).State = System.Data.Entity.EntityState.Modified; try { groupData.SaveChanges(); return(RedirectToAction("Index")); } catch { } ModelState.AddModelError("", "Unable to save changes made to the entity."); return(View(grp)); }
public ActionResult EditStudent(Student_Table stutable) { oprEntities editdb = new oprEntities(); editdb.Entry(stutable).State = EntityState.Modified; try { editdb.SaveChanges(); return(RedirectToAction("Index")); } catch { } ModelState.AddModelError("", "Data Cannot edit "); return(View(editdb)); }
public ActionResult EditClass(opr.Models.ClassesTable model) { oprEntities cls = new oprEntities(); model.IsDeleted = true; model.IsActive = true; cls.Entry(model).State = System.Data.Entity.EntityState.Modified; try { cls.SaveChanges(); return(RedirectToAction("Index")); } catch { } ModelState.AddModelError("", "Unable to save changes"); return(View(model)); }
public ActionResult EditCampus(Campus_Table camtbl) { oprEntities camdb = new oprEntities(); camdb.Entry(camtbl).State = EntityState.Modified; try { camdb.SaveChanges(); return(RedirectToAction("Index")); } catch { } ModelState.AddModelError("", "Unable to Save Changes made to the Entity :("); return(View(camtbl)); }
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())); }
public string Create(opr.Models.CustomeFeild 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(); db.CustomeFeilds.Add(model); db.SaveChanges(); return("Saved successfully."); }