public ActionResult AddSpartan_RDM_Operations_Detail(int rowIndex = 0, int functionMode = 0, int id = 0) { int ModuleId = (Session["CurrentModuleId"] != null) ? Convert.ToInt32(Session["CurrentModuleId"]) : 0; ViewBag.currentRowIndex = rowIndex; ViewBag.functionMode = functionMode; ViewBag.Consult = false; var permission = PermissionHelper.GetRoleObjectPermission(SessionHelper.Role, 45363); ViewBag.Permission = permission; if (!_tokenManager.GenerateToken()) { return(null); } _ISpartan_RDM_Operations_DetailApiConsumer.SetAuthHeader(_tokenManager.Token); Spartan_RDM_Operations_DetailModel varSpartan_RDM_Operations_Detail = new Spartan_RDM_Operations_DetailModel(); if (id.ToString() != "0") { var Spartan_RDM_Operations_DetailsData = _ISpartan_RDM_Operations_DetailApiConsumer.ListaSelAll(0, 1000, "Spartan_RDM_Operations_Detail.DetailId=" + id, "").Resource.Spartan_RDM_Operations_Details; if (Spartan_RDM_Operations_DetailsData != null && Spartan_RDM_Operations_DetailsData.Count > 0) { var Spartan_RDM_Operations_DetailData = Spartan_RDM_Operations_DetailsData.First(); varSpartan_RDM_Operations_Detail = new Spartan_RDM_Operations_DetailModel { DetailId = Spartan_RDM_Operations_DetailData.DetailId , Object_Name = Spartan_RDM_Operations_DetailData.Object_Name , Object_NameDescription = CultureHelper.GetTraduction(Convert.ToString(Spartan_RDM_Operations_DetailData.Object_Name), "Spartan_Object_ByPass") ?? (string)Spartan_RDM_Operations_DetailData.Object_Name_Spartan_Object_ByPass.Description , Object_Label = Spartan_RDM_Operations_DetailData.Object_Label , Order_Shown = Spartan_RDM_Operations_DetailData.Order_Shown , Count_Query = Spartan_RDM_Operations_DetailData.Count_Query , Query_Data = Spartan_RDM_Operations_DetailData.Query_Data , Icono = Spartan_RDM_Operations_DetailData.Icono }; } _ISpartane_FileApiConsumer.SetAuthHeader(_tokenManager.Token); ViewBag.IconoSpartane_File = _ISpartane_FileApiConsumer.GetByKey(varSpartan_RDM_Operations_Detail.Icono).Resource; } if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } _ISpartan_Object_ByPassApiConsumer.SetAuthHeader(_tokenManager.Token); var Spartan_Object_ByPasss_Object_Name = _ISpartan_Object_ByPassApiConsumer.SelAll(true); if (Spartan_Object_ByPasss_Object_Name != null && Spartan_Object_ByPasss_Object_Name.Resource != null) { ViewBag.Spartan_Object_ByPasss_Object_Name = Spartan_Object_ByPasss_Object_Name.Resource.Where(m => m.Description != null).OrderBy(m => m.Description).Select(m => new SelectListItem { Text = CultureHelper.GetTraduction(Convert.ToString(m.ObjectId), "Spartan_Object_ByPass", "Description") ?? m.Description.ToString(), Value = Convert.ToString(m.ObjectId) }).ToList(); } return(PartialView("AddSpartan_RDM_Operations_Detail", varSpartan_RDM_Operations_Detail)); }
public ActionResult Post(bool IsNew, Spartan_RDM_Operations_DetailModel varSpartan_RDM_Operations_Detail) { try { if (ModelState.IsValid) { if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } _ISpartan_RDM_Operations_DetailApiConsumer.SetAuthHeader(_tokenManager.Token); if (varSpartan_RDM_Operations_Detail.IconoRemoveAttachment != 0 && varSpartan_RDM_Operations_Detail.IconoFile == null) { varSpartan_RDM_Operations_Detail.Icono = 0; } if (varSpartan_RDM_Operations_Detail.IconoFile != null) { var fileAsBytes = HttpPostedFileHelper.GetPostedFileAsBytes(varSpartan_RDM_Operations_Detail.IconoFile); _ISpartane_FileApiConsumer.SetAuthHeader(_tokenManager.Token); varSpartan_RDM_Operations_Detail.Icono = (int)_ISpartane_FileApiConsumer.Insert(new Spartane_File() { File = fileAsBytes, Description = varSpartan_RDM_Operations_Detail.IconoFile.FileName, File_Size = fileAsBytes.Length }).Resource; } var result = ""; var Spartan_RDM_Operations_DetailInfo = new Spartan_RDM_Operations_Detail { DetailId = varSpartan_RDM_Operations_Detail.DetailId , Object_Name = varSpartan_RDM_Operations_Detail.Object_Name , Object_Label = varSpartan_RDM_Operations_Detail.Object_Label , Order_Shown = varSpartan_RDM_Operations_Detail.Order_Shown , Count_Query = varSpartan_RDM_Operations_Detail.Count_Query , Query_Data = varSpartan_RDM_Operations_Detail.Query_Data , Icono = (varSpartan_RDM_Operations_Detail.Icono.HasValue && varSpartan_RDM_Operations_Detail.Icono != 0) ? ((int?)Convert.ToInt32(varSpartan_RDM_Operations_Detail.Icono.Value)) : null }; result = !IsNew? _ISpartan_RDM_Operations_DetailApiConsumer.Update(Spartan_RDM_Operations_DetailInfo, null, null).Resource.ToString() : _ISpartan_RDM_Operations_DetailApiConsumer.Insert(Spartan_RDM_Operations_DetailInfo, null, null).Resource.ToString(); 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) { int ModuleId = (Session["CurrentModuleId"] != null) ? Convert.ToInt32(Session["CurrentModuleId"]) : 0; var permission = PermissionHelper.GetRoleObjectPermission(SessionHelper.Role, 45363); ViewBag.Permission = permission; var varSpartan_RDM_Operations_Detail = new Spartan_RDM_Operations_DetailModel(); ViewBag.ObjectId = "45363"; 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_RDM_Operations_DetailApiConsumer.SetAuthHeader(_tokenManager.Token); var Spartan_RDM_Operations_DetailData = _ISpartan_RDM_Operations_DetailApiConsumer.GetByKeyComplete(Id).Resource.Spartan_RDM_Operations_Details[0]; if (Spartan_RDM_Operations_DetailData == null) { return(HttpNotFound()); } varSpartan_RDM_Operations_Detail = new Spartan_RDM_Operations_DetailModel { DetailId = (int)Spartan_RDM_Operations_DetailData.DetailId , Object_Name = Spartan_RDM_Operations_DetailData.Object_Name , Object_NameDescription = CultureHelper.GetTraduction(Convert.ToString(Spartan_RDM_Operations_DetailData.Object_Name), "Spartan_Object_ByPass") ?? (string)Spartan_RDM_Operations_DetailData.Object_Name_Spartan_Object_ByPass.Description , Object_Label = Spartan_RDM_Operations_DetailData.Object_Label , Order_Shown = Spartan_RDM_Operations_DetailData.Order_Shown , Count_Query = Spartan_RDM_Operations_DetailData.Count_Query , Query_Data = Spartan_RDM_Operations_DetailData.Query_Data , Icono = Spartan_RDM_Operations_DetailData.Icono }; _ISpartane_FileApiConsumer.SetAuthHeader(_tokenManager.Token); ViewBag.IconoSpartane_File = _ISpartane_FileApiConsumer.GetByKey(varSpartan_RDM_Operations_Detail.Icono).Resource; } if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } _ISpartan_Object_ByPassApiConsumer.SetAuthHeader(_tokenManager.Token); var Spartan_Object_ByPasss_Object_Name = _ISpartan_Object_ByPassApiConsumer.SelAll(true); if (Spartan_Object_ByPasss_Object_Name != null && Spartan_Object_ByPasss_Object_Name.Resource != null) { ViewBag.Spartan_Object_ByPasss_Object_Name = Spartan_Object_ByPasss_Object_Name.Resource.Where(m => m.Description != null).OrderBy(m => m.Description).Select(m => new SelectListItem { Text = CultureHelper.GetTraduction(Convert.ToString(m.ObjectId), "Spartan_Object_ByPass", "Description") ?? m.Description.ToString(), Value = Convert.ToString(m.ObjectId) }).ToList(); } ViewBag.Consult = consult == 1; if (consult == 1) { ViewBag.Operation = "Consult"; } return(View(varSpartan_RDM_Operations_Detail)); }