Ejemplo n.º 1
0
        public async Task <CountryDto> UpdateAsync(string id, CountryRequestModel requestModel)
        {
            if (!await _countryRepository.AnyAsync(country => country.Id == id))
            {
                throw new ItemNotFoundException(id);
            }

            await CheckCountryExist(requestModel, id);

            var updatedCountry = await _countryRepository.UpdateAsync(id, _mapper.Map <Country>(requestModel));

            return(_mapper.Map <CountryDto>(updatedCountry));
        }
Ejemplo n.º 2
0
        public async Task <DistrictDto> UpdateAsync(string id, DistrictRequestModel requestModel)
        {
            if (!await _districtRepository.AnyAsync(district => district.Id == id))
            {
                throw new ItemNotFoundException(requestModel.Name);
            }

            if (!await _cityRepository.AnyAsync(city => city.Id == requestModel.CityId))
            {
                throw new NotFoundException($"City not found for Id:{requestModel.CityId}");
            }

            await CheckDistrictExist(requestModel, id);

            var updatedDistrict = await _districtRepository.UpdateAsync(id, _mapper.Map <District>(requestModel));

            return(_mapper.Map <DistrictDto>(updatedDistrict));
        }
Ejemplo n.º 3
0
        public async Task <CityDto> UpdateAsync(string id, CityRequestModel requestModel)
        {
            if (!await _cityRepository.AnyAsync(city => city.Id == id))
            {
                throw new ItemNotFoundException(requestModel.Name);
            }

            if (!await _countryRepository.AnyAsync(country => country.Id == requestModel.CountryId))
            {
                throw new NotFoundException($"Country not found for Id:{requestModel.CountryId}");
            }

            await CheckCityExist(requestModel, id);

            var updatedCity = await _cityRepository.UpdateAsync(id, _mapper.Map <City>(requestModel));

            return(_mapper.Map <CityDto>(updatedCity));
        }
Ejemplo n.º 4
0
 public Task <bool> AnyAsync(Expression <Func <User, bool> > predicate)
 {
     return(_mongoRepository.AnyAsync(predicate));
 }