public ActionResult Post(bool IsNew, Spartan_ObjectModel varSpartan_Object) { try { //if (ModelState.IsValid) //{ if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } _ISpartan_ObjectApiConsumer.SetAuthHeader(_tokenManager.Token); var result = ""; var Spartan_ObjectInfo = new Spartane.Core.Domain.Spartan_Object.Spartan_Object { Object_Id = varSpartan_Object.Object_Id , Name = varSpartan_Object.Name }; result = !IsNew? _ISpartan_ObjectApiConsumer.Update(Spartan_ObjectInfo, null, null).Resource.ToString() : _ISpartan_ObjectApiConsumer.Insert(Spartan_ObjectInfo, null, null).Resource.ToString(); Session["KeyValueInserted"] = result; return(Json(result, JsonRequestBehavior.AllowGet)); //} //return Json(false, JsonRequestBehavior.AllowGet); } catch (ServiceException ex) { return(Json(false, JsonRequestBehavior.AllowGet)); } }
public ActionResult Create(int Id = 0, int consult = 0) { var permission = PermissionHelper.GetRoleObjectPermission(SessionHelper.Role, 32554); ViewBag.Permission = permission; var varSpartan_Object = new Spartan_ObjectModel(); ViewBag.ObjectId = "32554"; ViewBag.Operation = "New"; ViewBag.IsNew = true; if ((Id.GetType() == typeof(string) && Id.ToString() != "") || ((Id.GetType() == typeof(int) || Id.GetType() == typeof(Int16) || Id.GetType() == typeof(Int32) || Id.GetType() == typeof(Int64) || Id.GetType() == typeof(short)) && Id.ToString() != "0")) { ViewBag.IsNew = false; ViewBag.Operation = "Update"; if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } _ISpartan_ObjectApiConsumer.SetAuthHeader(_tokenManager.Token); var Spartan_ObjectData = _ISpartan_ObjectApiConsumer.GetByKeyComplete(Id).Resource.Spartan_Objects[0]; if (Spartan_ObjectData == null) { return(HttpNotFound()); } varSpartan_Object = new Spartan_ObjectModel { Object_Id = (int)Spartan_ObjectData.Object_Id , Name = Spartan_ObjectData.Name }; } if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } ViewBag.Consult = consult == 1; if (consult == 1) { ViewBag.Operation = "Consult"; } return(View(varSpartan_Object)); }
public ActionResult AddSpartan_Object(int rowIndex = 0, int functionMode = 0, string id = "0") { ViewBag.currentRowIndex = rowIndex; ViewBag.functionMode = functionMode; ViewBag.Consult = false; var permission = PermissionHelper.GetRoleObjectPermission(SessionHelper.Role, 32554); ViewBag.Permission = permission; if (!_tokenManager.GenerateToken()) { return(null); } _ISpartan_ObjectApiConsumer.SetAuthHeader(_tokenManager.Token); Spartan_ObjectModel varSpartan_Object = new Spartan_ObjectModel(); if (id.ToString() != "0") { var Spartan_ObjectsData = _ISpartan_ObjectApiConsumer.ListaSelAll(0, 1000, "Object_Id=" + id, "").Resource.Spartan_Objects; if (Spartan_ObjectsData != null && Spartan_ObjectsData.Count > 0) { var Spartan_ObjectData = Spartan_ObjectsData.First(); varSpartan_Object = new Spartan_ObjectModel { Object_Id = Spartan_ObjectData.Object_Id , Name = Spartan_ObjectData.Name }; } } if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } return(PartialView("AddSpartan_Object", varSpartan_Object)); }