public HttpResponseMessage Post([FromBody] UserNeedleInventory item) { var test = "fail"; HttpResponseMessage response = new HttpResponseMessage(); try { var desc = db.NeedleDescriptionLookups .Where(b => b.systemDescription == item.systemName) .FirstOrDefault(); if (desc != null) { item.ravelryId = desc.id; item.ravelryName = desc.ravelryDescription; } item = db.UserNeedleInventories.Add(item); db.SaveChanges(); response = Request.CreateResponse <UserNeedleInventory>(HttpStatusCode.Created, item); string uri = Url.Link("DefaultApi", new { id = item.id }); response.Headers.Location = new Uri(uri); return(response); } catch (Exception ex) { test = ex.Message; } response.Headers.Location = new Uri(test); return(response); }
// PUT api/<controller>/5 public void Put(int id, [FromBody] UserNeedleInventory inventory) { }