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