Пример #1
0
        public async Task <ActionResult> GetAsync(int id)
        {
            BlCountry foundCountryBl = await _countryService.GetByIdAsync(id);

            Country foundCountry = _mapper.Map <Country>(foundCountryBl);

            if (foundCountry == null)
            {
                return(NotFound());
            }

            return(Ok(foundCountry));
        }
Пример #2
0
        public async Task <ActionResult> AddAsync([FromBody] Country country)
        {
            BlCountry countryBl = _mapper.Map <BlCountry>(country);

            AddResult addAddResult = await _countryService.AddAsync(countryBl);

            if (addAddResult.ResultType == ResultTypes.Duplicate)
            {
                return(BadRequest());
            }

            return(Ok(new { Id = addAddResult.ItemId }));
        }
Пример #3
0
        public async Task <ActionResult> UpdateAsync([FromBody] Country country)
        {
            BlCountry countryBl = _mapper.Map <BlCountry>(country);

            ResultTypes updateResult = await _countryService.UpdateAsync(countryBl);

            switch (updateResult)
            {
            case ResultTypes.NotFound:
                return(NotFound());

            case ResultTypes.Duplicate:
                return(BadRequest());
            }

            return(Ok());
        }