public HttpResponseMessage Post(RelationRepresentation representation) { try { var relation = Mapper.Map <IRelation>(representation); RelationService.Save(relation); return(Request.CreateResponse(HttpStatusCode.OK, CreateRepresentation(relation))); } catch (ModelValidationException exception) { return(Request.CreateResponse(HttpStatusCode.BadRequest, exception.Errors)); } }
public HttpResponseMessage Put(int id, RelationRepresentation rel) { try { var found = RelationService.GetById(id); if (found == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } Mapper.Map(rel, found); RelationService.Save(found); return(Request.CreateResponse(HttpStatusCode.OK, CreateRepresentation(found))); } catch (ModelValidationException exception) { return(Request.CreateResponse(HttpStatusCode.BadRequest, exception.Errors)); } }