public void NewGuest() // adds a new guest on click of create booking and links it to the rest of the guests booking { using (var context = new Hotel_Reservation_SystemEntities()) { var bookingID = context.Bookings.Select(b => b.BookingID).ToList().LastOrDefault(); var guest = new Guest { Name = this.Name, Email = this.Email, BookingIDFK = bookingID }; context.Guests.Add(guest); context.SaveChanges(); } }
public void NewBooking() // creates a new booking on click of create booking { using (var context = new Hotel_Reservation_SystemEntities()) { var booking = new Booking(); booking.BookingFrom = this.BookingFrom.ToString("dd-MM-yyyy"); booking.BookingTo = this.BookingTo.ToString("dd-MM-yyyy"); booking.NumOfGuests = this.GuestNumbers; booking.BookingDate = DateTime.Today.Date.ToString("dd-MM-yyyy"); booking.RoomBooked = this.RoomNumandCost; booking.RoomCost = this._roomcost; booking.RoomIDFK = Convert.ToInt32(_roomSelected); context.Bookings.Add(booking); context.SaveChanges(); } }