Пример #1
0
        public async Task <IActionResult> AddCountry([FromBody] CountryDto country)
        {
            var existingCountry = _countryMapperRepo.GetAll().FirstOrDefault(m => m.Name == country.Name);

            if (existingCountry != null)
            {
                return(BadRequest("Country already exists"));
            }

            try
            {
                await _countryMapperRepo.Add(country);

                return(Ok(country));
            }
            catch
            {
                return(BadRequest("country cannot be added"));
            }
        }