public async Task <HttpResponseMessage> CreateOrUpdate() { var requestContent = await Request.Content.ReadAsStringAsync(); Item item = JsonConvert.DeserializeObject <Item>(requestContent); return(Request.CreateResponse(HttpStatusCode.OK, _itemManagement.CreateOrUpdate(item))); }
public async Task <HttpResponseMessage> CreateOrUpdate([FromBody] Item item) { try { if (item == null) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } _itemManagement.CreateOrUpdate(item); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (DbUpdateException e) { return(Request.CreateResponse(HttpStatusCode.BadRequest, e.Message)); } }