public async Task <District> CreateAsync(InsertDistrictDto input, Country country) { var newDistrict = new District { Code = input.DistrictCode, Name = input.DistrictName, CountryId = country.Id, Country = country }; return(await _repository.InsertAsync(newDistrict)); }
public async Task <District> AddDistrict(InsertDistrictDto input) { var country = await _countryService.GetByExpression(p => p.Code.Equals(input.CountryCode)); if (country == null) { throw new MyAppException { ErrorCode = MyCustomErrorCodes.COUNTRY_NOT_FOUND }; } return(await _districtService.CreateAsync(input, country)); }
public async Task <IActionResult> AddDistrict([FromBody] InsertDistrictDto input) { var result = await _manager.AddDistrict(input); return(Ok(result)); }