public async Task <IActionResult> Post([FromBody] InsertRegionCountry model) { var result = await regionServices.Add(model); if (result.Status) { return(Ok(result)); } return(BadRequest(result)); }
public async Task <TypedResult <CountryDTO> > Add(InsertRegionCountry regionCountry) { try { RegionCountry existsRecord = (await regionCountryRepo.GetList(condition: x => x.Title.Equals(regionCountry.Title))).FirstOrDefault(); if (existsRecord != null) { throw new InvalidOperationException(ErrorMessages.THIS_RECORD_ALREADY_EXISTS); } RegionCountry entity = _mapper.Map <RegionCountry>(regionCountry); RegionCountry result = await regionCountryRepo.Add(entity); return(new TypedResult <CountryDTO>(_mapper.Map <CountryDTO>(result))); } catch (Exception ex) { return(new TypedResult <CountryDTO>(ex)); } }