public void addRoom(int numSingleBeds, int numDoubleBeds, int maxGuests, int singlePrice, int doublePrice, int extraPrice, int roomNumber, String extraFeatures) { using (var context = new HotelDBEntities()) { Room newRoom = new Room { numSingleBeds = numSingleBeds, numDoubleBeds = numDoubleBeds, maxGuests = maxGuests, singePrice = singlePrice, doublePrice = doublePrice, extraPrice = extraPrice, roomNumber = roomNumber, extraFeatures = extraFeatures}; context.Rooms.Add(newRoom); context.SaveChanges(); } }
public void createBilling(int guestPK, int roomCharge) { using (var context = new HotelDBEntities()) { Billing guestBilling = new Billing{guestIDFK = guestPK, roomCharge = roomCharge}; context.Billings.Add(guestBilling); context.SaveChanges(); } }
public Booking addBooking(int roomPK, string startDate, string endDate, int numGuests) { using (var context = new HotelDBEntities()) { Booking booking = new Booking {bookingStart = startDate, bookingEnd = endDate, roomIDFK = roomPK, numGuests = numGuests}; context.Bookings.Add(booking); context.SaveChanges(); return booking; } }
public static bool checkOut(int guestID) { using (var context = new HotelDBEntities()) { DateTime date = DateTime.Today; Guest guest = context.Guests.Find(guestID); context.Guests.Find(guestID).checkOutDate = date.ToShortDateString(); context.Guests.Find(guestID).Booking.bookingEnd = date.ToShortDateString(); context.SaveChanges(); return true; } }
public static void payBill(int guestPK) { using (var context = new HotelDBEntities()) { int billID = -1; foreach (var billing in context.Billings) if (billing.guestIDFK == guestPK) { billID = billing.billingID; break; } context.Billings.Find(billID).paid = true; context.SaveChanges(); } }
public static void addExtras(int guestPK, int extraCharges) { using (var context = new HotelDBEntities()) { int billID = -1;//out of range default initilization foreach (var billing in context.Billings) if (billing.guestIDFK == guestPK) { billID = billing.billingID; break; } context.Billings.Find(billID).billingExtras = extraCharges; context.SaveChanges(); } }
public static bool checkIn(int guestID) { using (var context = new HotelDBEntities()) { DateTime date = DateTime.Today; Guest guest = context.Guests.Find(guestID); if (DateUtil.compare(guest.Booking.bookingStart, date.ToShortDateString())) { context.Guests.Find(guestID).checkInDate = date.ToShortDateString(); context.SaveChanges(); MessageBox.Show("guest checked in"); return true; } MessageBox.Show("Please come back anytime after: " + guest.Booking.bookingStart); return false; } }
//remove a guest and other tables asscociated with it public static bool removeGuest(int guestId) { using (var context = new HotelDBEntities()) { foreach (var bill in context.Billings) { if (bill.guestIDFK == guestId) { context.Billings.Remove(bill); break; } } Guest g = context.Guests.Find(guestId); if (g != null) { context.Bookings.Remove(g.Booking); context.Guests.Remove(g); context.SaveChanges(); return true; } } return false; }
public void removeEverything() { using (var context = new HotelDBEntities()) { context.Billings.RemoveRange(context.Billings); context.Bookings.RemoveRange(context.Bookings); context.Guests.RemoveRange(context.Guests); context.Rooms.RemoveRange(context.Rooms); context.SaveChanges(); } }
public bool removeRoom(int roomId) { using (var context = new HotelDBEntities()) { Room room = context.Rooms.Find(roomId);//find entity by primary key if (room != null)//just incase! { context.Rooms.Remove(room); context.SaveChanges(); return true;//return true if succsessful removal of guest } } return false; }
public Guest addGuest(string name, int age, int bookingPK,string address, string comment) { using (var context = new HotelDBEntities()) { Guest newGuest = new Guest {name = name, age = age, bookingIDFK = bookingPK, address = address, comment = comment}; context.Guests.Add(newGuest); context.SaveChanges(); return newGuest; } }
public bool removeAllGuests() { using (var context = new HotelDBEntities()) { context.Billings.RemoveRange(context.Billings.ToArray()); context.Bookings.RemoveRange(context.Bookings.ToArray()); context.Guests.RemoveRange(context.Guests.ToArray()); context.SaveChanges(); if (context.Guests.Count(g => true) == 0) return true; } return false; }