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)); }
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)); }
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)); }
public Task <bool> AnyAsync(Expression <Func <User, bool> > predicate) { return(_mongoRepository.AnyAsync(predicate)); }