// POST api/SalesQuotationCategory public HttpResponseMessage PostSalesQuotationCategory(SalesQuotationCategory salesquotationcategory) { if (ModelState.IsValid) { salesquotationcategory.InsertBy = loginUser.UserID; db.SalesQuotationCategories.Add(salesquotationcategory); db.SaveChanges(); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, salesquotationcategory); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = salesquotationcategory.SalesQuotationCategoryID })); return response; } else { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } }
// PUT api/SalesQuotationCategory/5 public HttpResponseMessage PutSalesQuotationCategory(long id, SalesQuotationCategory salesquotationcategory) { if (!ModelState.IsValid) { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } if (id != salesquotationcategory.SalesQuotationCategoryID) { return Request.CreateResponse(HttpStatusCode.BadRequest); } salesquotationcategory.UpdateBy = loginUser.UserID; db.Entry(salesquotationcategory).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException ex) { return Request.CreateErrorResponse(HttpStatusCode.NotFound, ex); } return Request.CreateResponse(HttpStatusCode.OK); }