/// <summary> /// Gets all profiles in the database, in a paged order /// </summary> /// <param name="req">Filtering and searching parameters</param> public async Task <IEnumerable <Profile> > GetAllAsync(ProfileRequestParametersDto req) { var query = this._context.Profiles .Include(p => p.ListOfExps) .ThenInclude(i => i.ListOfExpsExperiences) .ThenInclude(le => le.Experience) .ThenInclude(e => e.Category) .AsQueryable().AsNoTracking(); if (!string.IsNullOrEmpty(req.SearchByFirstName)) { query = query.Where(x => x.FirstName.ToLower().Contains(req.SearchByFirstName.ToLower())); } if (!string.IsNullOrEmpty(req.SearchByLastName)) { query = query.Where(x => x.LastName.ToLower().Contains(req.SearchByLastName.ToLower())); } return(await PaginatedList <Profile> .CreateAsync(query, req.Page, req.PageSize)); }
public async Task <IActionResult> GetAllProfiles([FromQuery] ProfileRequestParametersDto req) { var foundProfiles = await _profileRepository.GetAllAsync(req); return(Ok(foundProfiles)); }