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