コード例 #1
0
 public JsonResult Delete(int id = 0)
 {
     try
     {
         BaseViewRelation model = db.BaseViewRelations.Find(id);
         if (model != null)
         {
             BoolString validation = model.BeforeDelete(db);
             if (validation.BoolValue)
             {
                 return(Json(new { Message = validation.StringValue }, JsonRequestBehavior.AllowGet));
             }
             db.BaseViewRelations.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 View Relation 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", "View Relation") }, JsonRequestBehavior.AllowGet));
     }
 }
コード例 #2
0
 public ActionResult Form(int id = 0, string from = "")
 {
     ViewBag.relations = db.VWISRElations.Where(d => d.PK_Table == "BaseViewRelation").ToList();
     ViewBag.from      = from;
     if (id == 0)
     {
         return(PartialView(new BaseViewRelation()));
     }
     else
     {
         BaseViewRelation model = db.BaseViewRelations.Find(id);
         return(PartialView(model));
     }
 }
コード例 #3
0
 public JsonResult Save(BaseViewRelation model)
 {
     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;
             db.SaveChanges();
             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 }));
             }
             db.BaseViewRelations.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 View Relation saved successfully." }));
     }
     catch (Exception ex)
     {
         return(Json(new { Message = Helper.ModeralException(ex).Replace("@table", "View Relation") }));
     }
 }