public async Task <ActionResult <PagedResponse <CharityResponseDto> > > GetCharitiesResticted([FromQuery] FilterCharityParams filterParams, [FromQuery] PaginationParams paginationParams) { PagedResponse <CharityResponseDto> pagedResponse = await CharitableEntityApplication.GetAllCharities((c) => (!c.IsActive && string.IsNullOrWhiteSpace(c.Approver)), filterParams, paginationParams, true); return(Ok(pagedResponse)); }
public async Task <PagedResponse <CharityResponseDto> > GetAllCharities(Expression <Func <CharitableEntity, bool> > predicate, FilterCharityParams filterParams, PaginationParams paginationParams, bool withInformation = false) { IQueryable <CharitableEntity> charitableEntities = null; charitableEntities = Repository.GetWhereAsQueryable(predicate); if (filterParams != null) { if (!string.IsNullOrEmpty(filterParams.State)) { charitableEntities = charitableEntities.Where(c => c.Address.State.ToLower().Contains(filterParams.State.ToLower(), StringComparison.InvariantCultureIgnoreCase)); } if (!string.IsNullOrEmpty(filterParams.City)) { charitableEntities = charitableEntities.Where(c => c.Address.City.ToLower().Contains(filterParams.City.ToLower(), StringComparison.InvariantCultureIgnoreCase)); } if (!string.IsNullOrEmpty(filterParams.Term)) { charitableEntities = charitableEntities.Where(c => c.Name.ToLower().Contains(filterParams.Term.ToLower(), StringComparison.InvariantCultureIgnoreCase) || c.Cnpj.ToLower().Contains(filterParams.Term.ToLower(), StringComparison.InvariantCultureIgnoreCase) || c.CharitableInformation.Nickname.ToLower().Contains(filterParams.Term.ToLower(), StringComparison.InvariantCultureIgnoreCase)); } } charitableEntities = charitableEntities.OrderBy(g => g.Name); if (withInformation) { charitableEntities = charitableEntities.Include(p => p.CharitableInformation); } PagedResponse <CharityResponseDto> pagedResponse = new PagedResponse <CharityResponseDto>(); pagedResponse = await pagedResponse.ToPagedResponse(charitableEntities, paginationParams, this.Mapper.Map <IEnumerable <CharityResponseDto> >); return(pagedResponse); }
public async Task <ActionResult <PagedResponse <CharityResponseDto> > > GetCharities([FromQuery] FilterCharityParams filterParams, [FromQuery] PaginationParams paginationParams) { PagedResponse <CharityResponseDto> pagedResponse = await CharitableEntityApplication.GetAllCharities((c) => (c.IsActive && c.Status.Equals(ApproverStatus.APPROVED) && c.CharitableInformation != null), filterParams, paginationParams, true); return(Ok(pagedResponse)); }