Ejemplo n.º 1
0
        public void AddGuest()
        {
            //add a new guest
            using (var context = new Sunshine_HotelEntities()) {
                //get the last booking ID from the new booking
                var bookingID = context.Bookings.Select(b => b.BookingID).ToList().LastOrDefault();

                //CREATE new entry
                var newGuest = new Guest
                {
                    Name = this.Name,
                    Address = this.Address,
                    NumberOfGuests = this.GuestNumbers,
                    RoomBooked = Convert.ToInt32(this.RoomSelected),
                    BookingIDFK = bookingID,  //get the booking ID from the booking table,  this
                    BookingDate = DateTime.Today.Date
                };
                context.Guests.Add(newGuest);
                context.SaveChanges();

                }
        }
Ejemplo n.º 2
0
        public void AddNewBooking()
        {
            using (var context = new Sunshine_HotelEntities()) {
                // CREATE a new booking
                var newbooking = new Booking();
                newbooking.RoomIDFK = Convert.ToInt32(this.RoomSelected);
                newbooking.BookingFrom = this.BookingFrom.Date;
                newbooking.BookingTo = this.BookingTo.Date;

                //add in the cost of the room extracted from the dictionary
                newbooking.RoomCost = RoomBookedPrice();
                context.Bookings.Add(newbooking);
                context.SaveChanges();

                //string BookedConfirmationMessage = Environment.NewLine + "You have booked Room " + this.RoomSelected + Environment.NewLine + "From " + this.BookingFrom + "To " + Environment.NewLine + this.BookingTo + Environment.NewLine + "For " + (string.Format("{0:C}", newbooking.RoomCost));

                //show a confirmation message
                //MessageBox.Show(BookedConfirmationMessage);

                }
        }