public HttpResponseMessage Post(MS_Uso_del_Ejercicio varMS_Uso_del_Ejercicio) { if (ModelState.IsValid) { var data = "-1"; try { data = Convert.ToString(this.service.Insert(varMS_Uso_del_Ejercicio)); var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_InsMS_Uso_del_Ejercicio", new JavaScriptSerializer().Serialize(varMS_Uso_del_Ejercicio), true); serviceBitacora.Insert(bitacora); } catch (ServiceException ex) { var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_InsMS_Uso_del_Ejercicio", new JavaScriptSerializer().Serialize(varMS_Uso_del_Ejercicio), true); serviceBitacora.Insert(bitacora); return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter)); } else { var errors = ModelState.SelectMany(m => m.Value.Errors.Select(err => err.ErrorMessage != string.Empty ? err.ErrorMessage : err.Exception.Message).ToList()).ToList(); var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_InsMS_Uso_del_Ejercicio", new JavaScriptSerializer().Serialize(varMS_Uso_del_Ejercicio), false, errors.ToString()); serviceBitacora.Insert(bitacora); return(Request.CreateResponse(HttpStatusCode.BadRequest, errors)); } }
public HttpResponseMessage Delete(int id) { MS_Uso_del_Ejercicio varMS_Uso_del_Ejercicio = this.service.GetByKey(id, false); bool result = false; if (varMS_Uso_del_Ejercicio == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } try { result = this.service.Delete(id);//, globalData, dataReference); var bitacora = BitacoraHelper.GetBitacora(Request, object_id, id, BitacoraHelper.TypeSql.DELETE, "sp_DelMS_Uso_del_Ejercicio", new JavaScriptSerializer().Serialize(varMS_Uso_del_Ejercicio), result); serviceBitacora.Insert(bitacora); } catch (ServiceException ex) { var bitacora = BitacoraHelper.GetBitacora(Request, object_id, id, BitacoraHelper.TypeSql.DELETE, "sp_DelMS_Uso_del_Ejercicio", new JavaScriptSerializer().Serialize(varMS_Uso_del_Ejercicio), result, ex.Message); serviceBitacora.Insert(bitacora); return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } return(Request.CreateResponse(HttpStatusCode.OK, result)); }
public ActionResult Post(bool IsNew, MS_Uso_del_EjercicioModel varMS_Uso_del_Ejercicio) { try { if (ModelState.IsValid) { if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } _IMS_Uso_del_EjercicioApiConsumer.SetAuthHeader(_tokenManager.Token); var result = ""; var MS_Uso_del_EjercicioInfo = new MS_Uso_del_Ejercicio { Folio = varMS_Uso_del_Ejercicio.Folio , Uso_del_Ejercicio = varMS_Uso_del_Ejercicio.Uso_del_Ejercicio }; result = !IsNew? _IMS_Uso_del_EjercicioApiConsumer.Update(MS_Uso_del_EjercicioInfo, null, null).Resource.ToString() : _IMS_Uso_del_EjercicioApiConsumer.Insert(MS_Uso_del_EjercicioInfo, null, null).Resource.ToString(); return(Json(result, JsonRequestBehavior.AllowGet)); } return(Json(false, JsonRequestBehavior.AllowGet)); } catch (ServiceException ex) { return(Json(false, JsonRequestBehavior.AllowGet)); } }
public HttpResponseMessage Get_Datos_Generales(int id) { MS_Uso_del_Ejercicio entity = this.service.ListaSelAll(1, 1, "MS_Uso_del_Ejercicio.Folio='" + id.ToString() + "'", "").MS_Uso_del_Ejercicios.First(); MS_Uso_del_Ejercicio result = new MS_Uso_del_Ejercicio(); result.Folio = entity.Folio; result.Uso_del_Ejercicio = entity.Uso_del_Ejercicio; result.Uso_del_Ejercicio_Tipo_de_Ejercicio_Rutina = entity.Uso_del_Ejercicio_Tipo_de_Ejercicio_Rutina; return(Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter)); }
public HttpResponseMessage PutTunnel(MS_Uso_del_Ejercicio emp, string user, string password) { var client = new System.Net.WebClient(); client.Headers = TokenManager.GetAuthenticationHeader(user, password); client.Headers["Content-Type"] = "application/json"; var dataString = new JavaScriptSerializer().Serialize(emp); var result = client.UploadString(new Uri(baseApi + ApiControllerUrl + "/Put?Id=" + emp.Folio), "PUT" , dataString); return(Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter)); }
public HttpResponseMessage Put_Datos_Generales(MS_Uso_del_Ejercicio varMS_Uso_del_Ejercicio_Datos_Generales) { var data = "-1"; try { data = Convert.ToString(this.service.Update_Datos_Generales(varMS_Uso_del_Ejercicio_Datos_Generales)); var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varMS_Uso_del_Ejercicio_Datos_Generales.Folio, BitacoraHelper.TypeSql.UPDATE, "sp_UpdMS_Uso_del_Ejercicio", new JavaScriptSerializer().Serialize(varMS_Uso_del_Ejercicio_Datos_Generales), true); serviceBitacora.Insert(bitacora); } catch (ServiceException ex) { var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varMS_Uso_del_Ejercicio_Datos_Generales.Folio, BitacoraHelper.TypeSql.UPDATE, "sp_UpdMS_Uso_del_Ejercicio", new JavaScriptSerializer().Serialize(varMS_Uso_del_Ejercicio_Datos_Generales), false, ex.Message); serviceBitacora.Insert(bitacora); return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter)); }
public HttpResponseMessage MS_Uso_del_EjercicioGenerateID() { MS_Uso_del_Ejercicio varMS_Uso_del_Ejercicio = new MS_Uso_del_Ejercicio(); var data = "-1"; try { data = Convert.ToString(this.service.Insert(varMS_Uso_del_Ejercicio)); var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_MS_Uso_del_EjercicioGenerateID", new JavaScriptSerializer().Serialize(varMS_Uso_del_Ejercicio), true); serviceBitacora.Insert(bitacora); } catch (ServiceException ex) { var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_MS_Uso_del_EjercicioGenerateID", new JavaScriptSerializer().Serialize(varMS_Uso_del_Ejercicio), true); serviceBitacora.Insert(bitacora); return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter)); }
public ActionResult Delete(int id) { try { if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } _IMS_Uso_del_EjercicioApiConsumer.SetAuthHeader(_tokenManager.Token); MS_Uso_del_Ejercicio varMS_Uso_del_Ejercicio = null; if (id.ToString() != "0") { string where = ""; } var result = _IMS_Uso_del_EjercicioApiConsumer.Delete(id, null, null).Resource; return(Json(result, JsonRequestBehavior.AllowGet)); } catch (ServiceException ex) { return(Json(false, JsonRequestBehavior.AllowGet)); } }