public HttpResponseMessage CreateAssetType([FromBody] AssetTypeDTO assetTypeDTO) { int newID = _assetService.CreateAssetType(assetTypeDTO); string uri = Url.Link("AssetTypeByIDRoute", new { id = newID }); // Generate a link to the new campus and set the location header in the response. var response = new HttpResponseMessage(HttpStatusCode.Created); response.Headers.Location = new System.Uri(uri); return(response); }
public IActionResult CreateType([FromBody] Requests.AssetTypeDto assetTypeDto) { // map dto to entity var assetType = _mapper.Map <AssetType>(assetTypeDto); try { // save _assetService.CreateAssetType(assetType); return(Ok()); } catch (AppException ex) { // return error message if there was an exception return(BadRequest(ex.Message)); } }