//cancel a room public static bool cancelBook(int idBook) { using (var context = new ValaisBookingEntities()) { Booking book = (Booking)context.Booking.Where(b => b.IdBooking == idBook).Single(); context.Booking.Remove(book); context.SaveChanges(); return(true); } }
//Book a room public static void book(DateTime checkin, DateTime checkout, String firstname, String lastname, decimal price, DateTime date, Room room) { using (var context = new ValaisBookingEntities()) { Booking book = new Booking(); book.CheckIn = checkin; book.CheckOut = checkout; book.Firstname = firstname; book.Lastname = lastname; book.Price = price; book.Date = date; book.IdRoom = room.IdRoom; context.Booking.Add(book); context.SaveChanges(); } }