public HttpResponseMessage Grabar(clsModelDGuardados pdatos) { HttpResponseMessage respuesta = new HttpResponseMessage(); // =============================================================================== // Para leer el TokenKey // =============================================================================== // https://www.guidgenerator.com/online-guid-generator.aspx clsTokenKey TokenKeyUtil = new clsTokenKey(); var headers = Request.Headers; string TokenKey = ""; if (headers.Contains("TokenKey")) { TokenKey = headers.GetValues("TokenKey").First(); } if (TokenKey.Length == 0) { return(Request.CreateErrorResponse(HttpStatusCode.Unauthorized, "Token Key Missing")); } if (!TokenKeyUtil.fnGetTokenKeyValido(TokenKey)) { return(Request.CreateErrorResponse(HttpStatusCode.Unauthorized, "Token Key Invalid or Inactive")); } // =============================================================================== try { clsModelEstatus msg = new clsModelEstatus(); Boolean lResult = fnSet(pdatos); if (lResult) { msg.Id = 0; msg.Mensaje = "Datos Actualizados"; respuesta = Request.CreateResponse(HttpStatusCode.OK, msg); } else { msg.Id = -1; msg.Mensaje = "No fue posible actualizar los datos ingresados favor reintentar"; respuesta = Request.CreateResponse(HttpStatusCode.Conflict, msg); } //clsModelEstatus Estado = new clsModelEstatus(); //Estado.Id = 0; //Estado.Mensaje = "Datos Actualizados"; //respuesta = Request.CreateResponse(HttpStatusCode.OK,Estado); } catch (Exception ex) { respuesta = Request.CreateErrorResponse(HttpStatusCode.Conflict, ex.Message.ToString() + ' ' + ex.InnerException.Message.ToString()); } return(respuesta); }
public HttpResponseMessage GetAll(List <clsModelDGuardadosOpc> param) { HttpResponseMessage respuesta = new HttpResponseMessage(); // =============================================================================== // Para leer el TokenKey // =============================================================================== // https://www.guidgenerator.com/online-guid-generator.aspx clsTokenKey TokenKeyUtil = new clsTokenKey(); var headers = Request.Headers; string TokenKey = ""; if (headers.Contains("TokenKey")) { TokenKey = headers.GetValues("TokenKey").First(); } if (TokenKey.Length == 0) { return(Request.CreateErrorResponse(HttpStatusCode.Unauthorized, "Token Key Missing")); } if (!TokenKeyUtil.fnGetTokenKeyValido(TokenKey)) { return(Request.CreateErrorResponse(HttpStatusCode.Unauthorized, "Token Key Invalid or Inactive")); } // =============================================================================== try { clsModelEstatus msg = new clsModelEstatus(); List <clsModelDGuardados> lResult = fnGetAll(param[0]); respuesta = Request.CreateResponse(HttpStatusCode.OK, lResult); } catch (Exception ex) { clsModelEstatus msg = new clsModelEstatus(); msg.Id = -1; msg.Mensaje = ex.Message.ToString() + ' ' + ex.InnerException.Message.ToString(); respuesta = Request.CreateResponse(HttpStatusCode.Conflict, msg); } return(respuesta); }