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, 45679); ViewBag.Permission = permission; var varDetalle_de_Documentos_Mandamiento_Judicial = new Detalle_de_Documentos_Mandamiento_JudicialModel(); ViewBag.ObjectId = "45679"; 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)); } _IDetalle_de_Documentos_Mandamiento_JudicialApiConsumer.SetAuthHeader(_tokenManager.Token); var Detalle_de_Documentos_Mandamiento_JudicialData = _IDetalle_de_Documentos_Mandamiento_JudicialApiConsumer.GetByKeyComplete(Id).Resource.Detalle_de_Documentos_Mandamiento_Judicials[0]; if (Detalle_de_Documentos_Mandamiento_JudicialData == null) { return(HttpNotFound()); } varDetalle_de_Documentos_Mandamiento_Judicial = new Detalle_de_Documentos_Mandamiento_JudicialModel { Clave = (int)Detalle_de_Documentos_Mandamiento_JudicialData.Clave , Documentos = Detalle_de_Documentos_Mandamiento_JudicialData.Documentos }; _ISpartane_FileApiConsumer.SetAuthHeader(_tokenManager.Token); ViewBag.DocumentosSpartane_File = _ISpartane_FileApiConsumer.GetByKey(varDetalle_de_Documentos_Mandamiento_Judicial.Documentos).Resource; } if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } ViewBag.Consult = consult == 1; if (consult == 1) { ViewBag.Operation = "Consult"; } return(View(varDetalle_de_Documentos_Mandamiento_Judicial)); }
public ActionResult Post(bool IsNew, Detalle_de_Documentos_Mandamiento_JudicialModel varDetalle_de_Documentos_Mandamiento_Judicial) { try { if (ModelState.IsValid) { if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } _IDetalle_de_Documentos_Mandamiento_JudicialApiConsumer.SetAuthHeader(_tokenManager.Token); if (varDetalle_de_Documentos_Mandamiento_Judicial.DocumentosRemoveAttachment != 0 && varDetalle_de_Documentos_Mandamiento_Judicial.DocumentosFile == null) { varDetalle_de_Documentos_Mandamiento_Judicial.Documentos = 0; } if (varDetalle_de_Documentos_Mandamiento_Judicial.DocumentosFile != null) { var fileAsBytes = HttpPostedFileHelper.GetPostedFileAsBytes(varDetalle_de_Documentos_Mandamiento_Judicial.DocumentosFile); _ISpartane_FileApiConsumer.SetAuthHeader(_tokenManager.Token); varDetalle_de_Documentos_Mandamiento_Judicial.Documentos = (int)_ISpartane_FileApiConsumer.Insert(new Spartane_File() { File = fileAsBytes, Description = varDetalle_de_Documentos_Mandamiento_Judicial.DocumentosFile.FileName, File_Size = fileAsBytes.Length }).Resource; } var result = ""; var Detalle_de_Documentos_Mandamiento_JudicialInfo = new Detalle_de_Documentos_Mandamiento_Judicial { Clave = varDetalle_de_Documentos_Mandamiento_Judicial.Clave , Documentos = (varDetalle_de_Documentos_Mandamiento_Judicial.Documentos.HasValue && varDetalle_de_Documentos_Mandamiento_Judicial.Documentos != 0) ? ((int?)Convert.ToInt32(varDetalle_de_Documentos_Mandamiento_Judicial.Documentos.Value)) : null }; result = !IsNew? _IDetalle_de_Documentos_Mandamiento_JudicialApiConsumer.Update(Detalle_de_Documentos_Mandamiento_JudicialInfo, null, null).Resource.ToString() : _IDetalle_de_Documentos_Mandamiento_JudicialApiConsumer.Insert(Detalle_de_Documentos_Mandamiento_JudicialInfo, null, null).Resource.ToString(); return(Json(result, JsonRequestBehavior.AllowGet)); } return(Json(false, JsonRequestBehavior.AllowGet)); } catch (ServiceException ex) { return(Json(false, JsonRequestBehavior.AllowGet)); } }
public ActionResult AddDetalle_de_Documentos_Mandamiento_Judicial(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, 45679); ViewBag.Permission = permission; if (!_tokenManager.GenerateToken()) { return(null); } _IDetalle_de_Documentos_Mandamiento_JudicialApiConsumer.SetAuthHeader(_tokenManager.Token); Detalle_de_Documentos_Mandamiento_JudicialModel varDetalle_de_Documentos_Mandamiento_Judicial = new Detalle_de_Documentos_Mandamiento_JudicialModel(); if (id.ToString() != "0") { var Detalle_de_Documentos_Mandamiento_JudicialsData = _IDetalle_de_Documentos_Mandamiento_JudicialApiConsumer.ListaSelAll(0, 1000, "Detalle_de_Documentos_Mandamiento_Judicial.Clave=" + id, "").Resource.Detalle_de_Documentos_Mandamiento_Judicials; if (Detalle_de_Documentos_Mandamiento_JudicialsData != null && Detalle_de_Documentos_Mandamiento_JudicialsData.Count > 0) { var Detalle_de_Documentos_Mandamiento_JudicialData = Detalle_de_Documentos_Mandamiento_JudicialsData.First(); varDetalle_de_Documentos_Mandamiento_Judicial = new Detalle_de_Documentos_Mandamiento_JudicialModel { Clave = Detalle_de_Documentos_Mandamiento_JudicialData.Clave , Documentos = Detalle_de_Documentos_Mandamiento_JudicialData.Documentos }; } _ISpartane_FileApiConsumer.SetAuthHeader(_tokenManager.Token); ViewBag.DocumentosSpartane_File = _ISpartane_FileApiConsumer.GetByKey(varDetalle_de_Documentos_Mandamiento_Judicial.Documentos).Resource; } if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } return(PartialView("AddDetalle_de_Documentos_Mandamiento_Judicial", varDetalle_de_Documentos_Mandamiento_Judicial)); }