public async Task <IHttpActionResult> getCamposDeActividad( [FromUri] int _paginaResp = 1, [FromUri] int _limiteResp = 50, [FromUri] string _ordenarResp = "nombre", [FromUri] string _ordenResp = "asc", [FromUri] string _filtroResp = null) { _ordenResp = _ordenResp.ToLower(); string[] camposOrdenarResp = { "titulo", "estado", "fechaRegistro", "creadaPorNombre", "asignadaANombre" }; string[] ordenValores = { "asc", "desc" }; if ( !camposOrdenarResp.Any(campo => campo == _ordenarResp) || !ordenValores.Any(ordValor => ordValor == _ordenResp) || _paginaResp < 1 || _limiteResp < 1) { ModelState.AddModelError("error", "Valores incorrectos en la query string"); return(BadRequest(ModelState)); } //Response.Headers.Add(Urls.HEADER_TOTAL_COUNT_SEC_RESPONSABLES, repoResponsable.TotalResponsables(_filtroResp).ToString()); var trabajadores = await repoTrabajadores.ListarAsync(_paginaResp - 1, _limiteResp, _ordenarResp, _ordenResp, _filtroResp); var resp = Request.CreateResponse <ActividadCamposDto>(HttpStatusCode.OK, new ActividadCamposDto { Trabajadores = trabajadores }); resp.Headers.Add(Urls.HEADER_ACCESS_CONTROL_EXPOSE, Urls.MY_HEADER_TOTAL_COUNT_SEC_RESPONSABLES); resp.Headers.Add(Urls.MY_HEADER_TOTAL_COUNT_SEC_RESPONSABLES, repoTrabajadores.TotalTrabajadores(_filtroResp).ToString()); return(ResponseMessage(resp)); }
public async Task <IHttpActionResult> GetTrabajadores( [FromUri] int _pagina = 1, [FromUri] int _limite = 50, [FromUri] string _ordenar = "nombre", [FromUri] string _orden = "asc", [FromUri] string _filtro = null ) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } //_orden = _orden.ToLower(); string[] camposOrdenar = { "nombre", "valor" }; string[] ordenValores = { "asc", "desc" }; if ( !camposOrdenar.Any(campo => campo == _ordenar) || !ordenValores.Any(ordValor => ordValor == _orden) || _pagina < 1 || _limite < 1) { ModelState.AddModelError("error", "Valores incorrectos en la query string"); return(BadRequest(ModelState)); } var trabajadores = await repo.ListarAsync(_pagina - 1, _limite, _ordenar, _orden, _filtro); //Access-Control-Expose-Headers: Access-Control-Allow-Origin //Access-Control-Expose-Headers Access-Control-Allow-Origin var resp = Request.CreateResponse <List <Trabajador> >(HttpStatusCode.OK, trabajadores); resp.Headers.Add(Urls.HEADER_ACCESS_CONTROL_EXPOSE, Urls.MY_HEADER_TOTAL_COUNT); resp.Headers.Add(Urls.MY_HEADER_TOTAL_COUNT, repo.TotalTrabajadores(_filtro).ToString()); //return resp; return(ResponseMessage(resp)); }