public ActionResult Detail(string id = "") { MD_SELECTION model = new MD_SELECTION(); if (!string.IsNullOrEmpty(id)) { var result = APIHelper.CallAPI <JsonResultObject <List <MD_SELECTION> > >("selection/getdetail", new { id = id }); if (result.IsOk) { model = result.dataObj.FirstOrDefault(); } } return(View(model)); }
public JsonResult Save(MD_SELECTION info) { if (info.ID != 0) { if (string.IsNullOrEmpty(info.NAME)) { return(Json(new JsonResultData { IsOk = false, dataErr = null, dataObj = null, Msg = "NAME can not be null", totalrows = 0 }, JsonRequestBehavior.AllowGet)); } if (string.IsNullOrEmpty(info.SHORTNAME)) { return(Json(new JsonResultData { IsOk = false, dataErr = null, dataObj = null, Msg = "SHORTNAME can not be null", totalrows = 0 }, JsonRequestBehavior.AllowGet)); } //update return(Json(APIHelper.CallAPI <JsonResultData>("selection/update", new { info.ID, info.NAME, info.SHORTNAME, info.VALUE }), JsonRequestBehavior.AllowGet)); } else { if (string.IsNullOrEmpty(info.NAME)) { return(Json(new JsonResultData { IsOk = false, dataErr = null, dataObj = null, Msg = "NAME can not be null", totalrows = 0 }, JsonRequestBehavior.AllowGet)); } if (string.IsNullOrEmpty(info.SHORTNAME)) { return(Json(new JsonResultData { IsOk = false, dataErr = null, dataObj = null, Msg = "SHORTNAME can not be null", totalrows = 0 }, JsonRequestBehavior.AllowGet)); } //insert return(Json(APIHelper.CallAPI <JsonResultData>("selection/insert", new { info.ID, info.NAME, info.SHORTNAME, info.VALUE }), JsonRequestBehavior.AllowGet)); } }