// POST api/Booking public HttpResponseMessage PostTblCustomerBooking(TblCustomerBooking tblcustomerbooking) { if (ModelState.IsValid) { _db.TblCustomerBookings.Add(tblcustomerbooking); _db.SaveChanges(); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, tblcustomerbooking); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = tblcustomerbooking.customer_id })); return response; } else { return Request.CreateResponse(HttpStatusCode.BadRequest); } }
// PUT api/Booking/5 public HttpResponseMessage PutTblCustomerBooking(int id, TblCustomerBooking tblcustomerbooking) { if (ModelState.IsValid && id == tblcustomerbooking.customer_id) { _db.Entry(tblcustomerbooking).State = EntityState.Modified; try { _db.SaveChanges(); } catch (DbUpdateConcurrencyException) { return Request.CreateResponse(HttpStatusCode.NotFound); } return Request.CreateResponse(HttpStatusCode.OK, tblcustomerbooking); } else { return Request.CreateResponse(HttpStatusCode.BadRequest); } }