// PUT api/Deals/5 public HttpResponseMessage Putdeal(int id, deal deal) { if (ModelState.IsValid && id == deal.DEALS_ID) { db.Entry(deal).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { return Request.CreateResponse(HttpStatusCode.NotFound); } return Request.CreateResponse(HttpStatusCode.OK); } else { return Request.CreateResponse(HttpStatusCode.BadRequest); } }
// POST api/Deals public HttpResponseMessage Postdeal(deal deal) { if (ModelState.IsValid) { db.deals.Add(deal); db.SaveChanges(); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, deal); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = deal.DEALS_ID })); return response; } else { return Request.CreateResponse(HttpStatusCode.BadRequest); } }