Ejemplo n.º 1
0
        public async Task <IEnumerable <Resident> > GetAllAsync(ResidentQuery queryFilter)
        {
            var query = _dbContext.Set <Resident>().AsQueryable();

            if (!string.IsNullOrEmpty(queryFilter.Name))
            {
                query = query.Where(x => x.Name.ToLower().Contains(queryFilter.Name.ToLower()));
            }

            if (!string.IsNullOrEmpty(queryFilter.Email))
            {
                query = query.Where(x => x.Email.Contains(queryFilter.Email));
            }

            if (!string.IsNullOrEmpty(queryFilter.Apartment))
            {
                query = query.Where(x => x.Apartment.Contains(queryFilter.Apartment));
            }

            if (!string.IsNullOrEmpty(queryFilter.Block))
            {
                query = query.Where(x => x.Block.Contains(queryFilter.Block));
            }

            return(await query.ToListAsync());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> GetAll(ResidentQuery queryFilter)
        {
            var residents = await _residentRepository.GetAllAsync(queryFilter);

            var result = _mapper.Map <IEnumerable <ResidentViewModel> >(residents);

            return(Ok(result));
        }