public IHttpActionResult PostGuestAndBookings(GuestAndBookings guestAndBookings) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.GuestAndBookings.Add(guestAndBookings); try { db.SaveChanges(); } catch (DbUpdateException) { if (GuestAndBookingsExists(guestAndBookings.Name)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = guestAndBookings.Name }, guestAndBookings)); }
public IHttpActionResult PutGuestAndBookings(string id, GuestAndBookings guestAndBookings) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != guestAndBookings.Name) { return(BadRequest()); } db.Entry(guestAndBookings).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!GuestAndBookingsExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetGuestAndBookings(string id) { GuestAndBookings guestAndBookings = db.GuestAndBookings.Find(id); if (guestAndBookings == null) { return(NotFound()); } return(Ok(guestAndBookings)); }
public IHttpActionResult DeleteGuestAndBookings(string id) { GuestAndBookings guestAndBookings = db.GuestAndBookings.Find(id); if (guestAndBookings == null) { return(NotFound()); } db.GuestAndBookings.Remove(guestAndBookings); db.SaveChanges(); return(Ok(guestAndBookings)); }