public JsonResult remove(int id = 0) { try { BaseTableContrain model = db.BaseTableContrains.Find(id); if (model != null) { BoolString validation = model.BeforeDelete(db); if (validation.BoolValue) { return(Json(new { Message = validation.StringValue }, JsonRequestBehavior.AllowGet)); } db.BaseTableContrains.Remove(model); db.SaveChanges(); validation = model.AfterDelete(db); if (validation.BoolValue) { return(Json(new { Message = validation.StringValue }, JsonRequestBehavior.AllowGet)); } return(Json(new { id = model.id, MessageSucess = "That Table Contrain deleted successfully." }, JsonRequestBehavior.AllowGet)); } return(Json(new { Message = "This record no longer exists" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { Message = Helper.ModeralException(ex).Replace("@table", "Table Contrain") }, JsonRequestBehavior.AllowGet)); } }
public JsonResult get(int id) { BaseTableContrain model = db.BaseTableContrains.Find(id); if (model != null) { return(Json(model, JsonRequestBehavior.AllowGet)); } else { return(Json(new { Message = "This record no longer exists" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Form(int id = 0, string from = "") { ViewBag.relations = db.VWISRElations.Where(d => d.PK_Table == "BaseTableContrain").ToList(); ViewBag.from = from; if (id == 0) { return(PartialView(new BaseTableContrain())); } else { BaseTableContrain model = db.BaseTableContrains.Find(id); return(PartialView(model)); } }
public JsonResult update(int id, BaseTableContrain model) { BoolString validation = model.BeforeEdit(db); if (validation.BoolValue) { return(Json(new { Message = validation.StringValue })); } db.Entry(model).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); validation = model.AfterEdit(db); if (validation.BoolValue) { return(Json(new { Message = validation.StringValue })); } return(Json(new { id = model.id, MessageSucess = "That Table Contrain saved successfully." })); }
public JsonResult create(BaseTableContrain model) { BoolString validation = model.BeforeSave(db); if (validation.BoolValue) { return(Json(new { Message = validation.StringValue })); } db.BaseTableContrains.Add(model); db.SaveChanges(); validation = model.AfterSave(db); if (validation.BoolValue) { return(Json(new { Message = validation.StringValue })); } return(Json(new { id = model.id, MessageSucess = "That Table Contrain saved successfully." })); }
public JsonResult Save(BaseTableContrain model, FormCollection form) { try { if (model.id != 0) { BoolString validation = model.BeforeEdit(db); if (validation.BoolValue) { return(Json(new { Message = validation.StringValue })); } db.Entry(model).State = System.Data.Entity.EntityState.Modified; validation = model.BeforeSave(db); if (validation.BoolValue) { return(Json(new { Message = validation.StringValue })); } validation = model.BeforeEdit(db); if (validation.BoolValue) { return(Json(new { Message = validation.StringValue })); } db.SaveChanges(); validation = model.AfterSave(db); if (validation.BoolValue) { return(Json(new { Message = validation.StringValue })); } validation = model.AfterEdit(db); if (validation.BoolValue) { return(Json(new { Message = validation.StringValue })); } } else { BoolString validation = model.BeforeSave(db); if (validation.BoolValue) { return(Json(new { Message = validation.StringValue })); } validation = model.BeforeCreate(db); if (validation.BoolValue) { return(Json(new { Message = validation.StringValue })); } db.BaseTableContrains.Add(model); db.SaveChanges(); validation = model.AfterSave(db); if (validation.BoolValue) { return(Json(new { Message = validation.StringValue })); } validation = model.AfterCreate(db); if (validation.BoolValue) { return(Json(new { Message = validation.StringValue })); } } return(Json(new { id = model.id, MessageSucess = "That Table Contrain saved successfully." })); } catch (Exception ex) { return(Json(new { Message = Helper.ModeralException(ex).Replace("@table", "Table Contrain") })); } }