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)); }
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 })); }
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()); }