예제 #1
0
        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));
        }
예제 #2
0
        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));
        }
예제 #3
0
        public async Task <IActionResult> AddDistrict([FromBody] InsertDistrictDto input)
        {
            var result = await _manager.AddDistrict(input);

            return(Ok(result));
        }