// POST api/SalesDeliveryDescription public HttpResponseMessage PostSalesDeliveryDescription(SalesDeliveryDescription salesdeliverydescription) { if (ModelState.IsValid) { //db.SalesDeliveryDescriptions.Add(salesdeliverydescription); salesdeliverydescription.InsertBy = loginUser.UserID; db.Entry(salesdeliverydescription).State = salesdeliverydescription.SalesDeliveryDescriptionID == 0 ? EntityState.Added : EntityState.Modified; db.SaveChanges(); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, salesdeliverydescription); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = salesdeliverydescription.SalesDeliveryDescriptionID })); return response; } else { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } }
// PUT api/SalesDeliveryDescription/5 public HttpResponseMessage PutSalesDeliveryDescription(long id, SalesDeliveryDescription salesdeliverydescription) { if (!ModelState.IsValid) { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } if (id != salesdeliverydescription.SalesDeliveryDescriptionID) { return Request.CreateResponse(HttpStatusCode.BadRequest); } salesdeliverydescription.UpdateBy = loginUser.UserID; db.Entry(salesdeliverydescription).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException ex) { return Request.CreateErrorResponse(HttpStatusCode.NotFound, ex); } return Request.CreateResponse(HttpStatusCode.OK); }