//Obtener Todos los registros de las personas public async Task <PagedList <Persona> > GetPersonas(PersonaQueryFilter filters) { filters.PageNumber = filters.PageNumber == 0 ? _paginationOptions.DefaultPageNumber : filters.PageNumber; filters.PageSize = filters.PageSize == 0 ? _paginationOptions.DefaultPageSize : filters.PageSize; var personas = await _personaRepository.GetPersonas(); if (filters.Nombre != null) { personas = personas.Where(x => x.Nombre.ToLower().Contains(filters.Nombre.ToLower())); } if (filters.ApellidoP != null) { personas = personas.Where(x => x.ApellidoPaterno.ToLower().Contains(filters.ApellidoP.ToLower())); } if (filters.ApellidoM != null) { personas = personas.Where(x => x.ApellidoMaterno.ToLower().Contains(filters.ApellidoM.ToLower())); } if (filters.Edad != null) { personas = personas.Where(x => x.Edad.ToLower().Contains(filters.Edad.ToLower())); } var pagedPosts = PagedList <Persona> .Create(personas, filters.PageNumber, filters.PageSize); return(pagedPosts); }
public async Task <IActionResult> GetPersonasTDS(string nombreTD, [FromQuery] PersonaQueryFilter filters) { var personasTDS = await _personaService.GetPersonasTDS(nombreTD, filters); var personasTDSDto = _mapper.Map <IEnumerable <PersonaDto> >(personasTDS); var metadata = new Metadata { TotalCount = personasTDS.TotalCount, PageSize = personasTDS.PageSize, ActualPage = personasTDS.ActualPage, TotalPages = personasTDS.TotalPages, HasNextPage = personasTDS.HasNextPage, HasPreviousPage = personasTDS.HasPreviousPage }; var response = new ApiResponse <IEnumerable <PersonaDto> >(personasTDSDto) { Meta = metadata }; Response.Headers.Add("X-Paginations", JsonConvert.SerializeObject(metadata)); return(Ok(response)); }
public async Task <IActionResult> GetPersonas([FromQuery] PersonaQueryFilter filters) { var personas = await _personaService.GetPersonas(filters); var personasDtos = _mapper.Map <IEnumerable <PersonaDto> >(personas); var metadata = new Metadata { TotalCount = personas.TotalCount, PageSize = personas.PageSize, ActualPage = personas.ActualPage, TotalPages = personas.TotalPages, HasNextPage = personas.HasNextPage, HasPreviousPage = personas.HasPreviousPage, NextPageUrl = _uriService.GetPersonaPaginationUri(filters, Url.RouteUrl(nameof(GetPersonas))).ToString(), PreviousPageUrl = _uriService.GetPersonaPaginationUri(filters, Url.RouteUrl(nameof(GetPersonas))).ToString() }; var response = new ApiResponse <IEnumerable <PersonaDto> >(personasDtos) { Meta = metadata }; Response.Headers.Add("X-Pagination", JsonConvert.SerializeObject(metadata)); return(Ok(response)); }
//--Activos public async Task <PagedList <Persona> > GetPersonasActivos(bool activo, PersonaQueryFilter filters) { var personasss = await _personaRepository.GetPersonasActivos(activo); filters.PageNumber = filters.PageNumber == 0 ? _paginationOptions.DefaultPageNumber : filters.PageNumber; filters.PageSize = filters.PageSize == 0 ? _paginationOptions.DefaultPageSize : filters.PageSize; personasss = personasss.Where(x => x.Activo == activo); var pagedPostts = PagedList <Persona> .Create(personasss, filters.PageNumber, filters.PageSize); return(pagedPostts); }
//Filtros public async Task <PagedList <Persona> > GetPersonasTDS(string nombreTD, PersonaQueryFilter filters) { var personass = await _personaRepository.GetPersonasTDS(nombreTD); filters.PageNumber = filters.PageNumber == 0 ? _paginationOptions.DefaultPageNumber : filters.PageNumber; filters.PageSize = filters.PageSize == 0 ? _paginationOptions.DefaultPageSize : filters.PageSize; personass = personass.Where(x => x.Nombre.Contains(nombreTD) || x.Edad == nombreTD || x.ApellidoPaterno.Contains(nombreTD) || x.ApellidoMaterno.Contains(nombreTD)); var pagedPosts = PagedList <Persona> .Create(personass, filters.PageNumber, filters.PageSize); return(pagedPosts); }
public Task GetPersonasTDS(PersonaQueryFilter filters) { throw new NotImplementedException(); }
public Uri GetPersonaPaginationUri(PersonaQueryFilter filters, string actionUrl) { string baseUrl = $"{_baseUri}{actionUrl}"; return(new Uri(baseUrl)); }