public async Task <IActionResult> Post([FromBody] InsertRegionCity model) { var result = await regionServices.Add(model); if (result.Status) { return(Ok(result)); } return(BadRequest(result)); }
public async Task <TypedResult <CityDTO> > Add(InsertRegionCity regionCity) { try { ICollection <RegionCity> existsRecords = await regionCityRepo .GetList(condition : x => x.RegionStateId == regionCity.StateId && x.Title.Equals(regionCity.Title)); if (existsRecords.Any()) { throw new InvalidOperationException(ErrorMessages.THIS_RECORD_ALREADY_EXISTS); } RegionCity entity = _mapper.Map <RegionCity>(regionCity); RegionCity result = await regionCityRepo.Add(entity); return(new TypedResult <CityDTO>(_mapper.Map <CityDTO>(result))); } catch (Exception ex) { return(new TypedResult <CityDTO>(ex)); } }