public async void GetSheltersReturnsDogsForNotEmptyDatabase()
        {
            var addShelter = GetValidShelter();
            var addResult  = await shelterRepository.AddShelter(addShelter);

            Assert.True(addResult.Successful);

            var result = await shelterRepository.GetShelters(null, null, 0, 5);

            Assert.True(result.Successful);
            Assert.True(result.Data.Count > 0);
        }
Esempio n. 2
0
        public IActionResult GetShelters()
        {
            var shelters = shelterRepo.GetShelters();
            var dto      = new List <ShelterDto>();

            foreach (var shelter in shelters)
            {
                dto.Add(mapper.Map <ShelterDto>(shelter));
            }
            return(Ok(dto));
        }
Esempio n. 3
0
        public async Task <ServiceResponse <List <ShelterDto>, int> > GetShelters(string name, string sort, int page, int size)
        {
            var repoResponse = await shelterRepository.GetShelters(name, sort, page, size);

            var serviceResponse = mapper.Map <ServiceResponse <List <ShelterDto>, int> >(repoResponse);

            if (!serviceResponse.Successful)
            {
                serviceResponse.StatusCode = StatusCodes.Status400BadRequest;
            }
            return(serviceResponse);
        }