public ActionResult Post(bool IsNew, Detalle_Medios_Prueba_ImputadoModel varDetalle_Medios_Prueba_Imputado) { try { if (ModelState.IsValid) { if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } _IDetalle_Medios_Prueba_ImputadoApiConsumer.SetAuthHeader(_tokenManager.Token); if (varDetalle_Medios_Prueba_Imputado.Archivo_AdjuntoRemoveAttachment != 0 && varDetalle_Medios_Prueba_Imputado.Archivo_AdjuntoFile == null) { varDetalle_Medios_Prueba_Imputado.Archivo_Adjunto = 0; } if (varDetalle_Medios_Prueba_Imputado.Archivo_AdjuntoFile != null) { var fileAsBytes = HttpPostedFileHelper.GetPostedFileAsBytes(varDetalle_Medios_Prueba_Imputado.Archivo_AdjuntoFile); _ISpartane_FileApiConsumer.SetAuthHeader(_tokenManager.Token); varDetalle_Medios_Prueba_Imputado.Archivo_Adjunto = (int)_ISpartane_FileApiConsumer.Insert(new Spartane_File() { File = fileAsBytes, Description = varDetalle_Medios_Prueba_Imputado.Archivo_AdjuntoFile.FileName, File_Size = fileAsBytes.Length }).Resource; } var result = ""; var Detalle_Medios_Prueba_ImputadoInfo = new Detalle_Medios_Prueba_Imputado { Clave = varDetalle_Medios_Prueba_Imputado.Clave , Medio_de_Prueba_Presentado = varDetalle_Medios_Prueba_Imputado.Medio_de_Prueba_Presentado , Fecha_de_Presentacion = (!String.IsNullOrEmpty(varDetalle_Medios_Prueba_Imputado.Fecha_de_Presentacion)) ? DateTime.ParseExact(varDetalle_Medios_Prueba_Imputado.Fecha_de_Presentacion, ConfigurationProperty.DateFormat, CultureInfo.InvariantCulture as IFormatProvider) : (DateTime?)null , Archivo_Adjunto = (varDetalle_Medios_Prueba_Imputado.Archivo_Adjunto.HasValue && varDetalle_Medios_Prueba_Imputado.Archivo_Adjunto != 0) ? ((int?)Convert.ToInt32(varDetalle_Medios_Prueba_Imputado.Archivo_Adjunto.Value)) : null }; result = !IsNew? _IDetalle_Medios_Prueba_ImputadoApiConsumer.Update(Detalle_Medios_Prueba_ImputadoInfo, null, null).Resource.ToString() : _IDetalle_Medios_Prueba_ImputadoApiConsumer.Insert(Detalle_Medios_Prueba_ImputadoInfo, null, null).Resource.ToString(); return(Json(result, JsonRequestBehavior.AllowGet)); } return(Json(false, JsonRequestBehavior.AllowGet)); } catch (ServiceException ex) { return(Json(false, JsonRequestBehavior.AllowGet)); } }
public ActionResult Delete(int id) { try { if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } _IDetalle_Medios_Prueba_ImputadoApiConsumer.SetAuthHeader(_tokenManager.Token); Detalle_Medios_Prueba_Imputado varDetalle_Medios_Prueba_Imputado = null; if (id.ToString() != "0") { string where = ""; } var result = _IDetalle_Medios_Prueba_ImputadoApiConsumer.Delete(id, null, null).Resource; return(Json(result, JsonRequestBehavior.AllowGet)); } catch (ServiceException ex) { return(Json(false, JsonRequestBehavior.AllowGet)); } }