public IHttpActionResult Put(int id, [FromBody] PropertyMappingViewModel propertyMapping) { try { if (propertyMapping == null) { return(BadRequest("PropertyMapping cannot be null")); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var updatedPropertyMapping = _repository.Update(Mapper.Map <PropertyMapping>(propertyMapping)); if (updatedPropertyMapping == null) { return(NotFound()); } return(Ok(updatedPropertyMapping)); } catch (Exception ex) { return(InternalServerError(ex)); } }
public IHttpActionResult Post([FromBody] PropertyMappingViewModel propertyMapping) { try { if (propertyMapping == null) { return(BadRequest("PropertyMapping cannot be null")); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var newPropertyMapping = _repository.Add(Mapper.Map <PropertyMapping>(propertyMapping)); if (newPropertyMapping == null) { return(Conflict()); } return(Created(Request.RequestUri + newPropertyMapping.Id.ToString(), Mapper.Map <PropertyMappingViewModel>(newPropertyMapping))); } catch (Exception ex) { return(InternalServerError(ex)); } }