public List <Room> GetRoomsAvailable(DateTime Datum1, DateTime Datum2) { var Lista = new List <Room>(); var IntList = new List <int>(); var Rooms = GetRooms(); var StartDate = Datum1.Date; var EndDate = Datum2.Date; using (var db = new HotelCaliforniaEntities()) { foreach (var Book in db.Bookings) { if (((StartDate >= Book.DateStart && StartDate < Book.DateEnd) || (EndDate > Book.DateStart && EndDate <= Book.DateEnd)) || ((Book.DateStart >= StartDate && Book.DateStart < EndDate) || (Book.DateEnd > StartDate && Book.DateEnd <= EndDate))) { IntList.Add(Book.RoomID); } } Lista = db.Rooms.Where(x => !IntList.Contains(x.RoomID)).ToList(); } return(Lista); }
public bool CheckRoomAvailable(int CustomerID, Room R, DateTime Datum1, DateTime Datum2) { var StartDate = Datum1.Date; var EndDate = Datum2.Date; bool Booked = true; using (var db = new HotelCaliforniaEntities()) { foreach (var Book in db.Bookings) { if (((StartDate >= Book.DateStart && StartDate < Book.DateEnd) || (EndDate > Book.DateStart && EndDate <= Book.DateEnd)) || ((Book.DateStart >= StartDate && Book.DateStart < EndDate) || (Book.DateEnd > StartDate && Book.DateEnd <= EndDate))) { if ((Book.CustomerID != CustomerID) && (Book.RoomID == R.RoomID)) { Booked = false; } } else { Booked = true; } } } return(Booked); }
public void UpdateBooking(Booking B) { using (var db = new HotelCaliforniaEntities()) { db.Bookings.AddOrUpdate(B); db.SaveChanges(); } }
public void AddCustomer(Customer C) { using (var Data = new HotelCaliforniaEntities()) { Data.Customers.Add(C); Data.SaveChanges(); } }
public void BookARoom(Booking B) { using (var db = new HotelCaliforniaEntities()) { db.Bookings.Add(B); db.SaveChanges(); } }
public void DeleteCustomer(Customer C) { using (var db = new HotelCaliforniaEntities()) { var Item = db.Customers.SingleOrDefault(x => x.CustomerID == C.CustomerID); db.Customers.Remove(Item); db.SaveChanges(); } }
public Room GetRoom(int Room_ID) { var R = new Room(); using (var db = new HotelCaliforniaEntities()) { R = (from r in db.Rooms where r.RoomID == Room_ID select r).FirstOrDefault(); } return(R); }
public Customer FindACustomer(int id) { var C = new Customer(); using (HotelCaliforniaEntities db = new HotelCaliforniaEntities()) { C = db.Customers.Where(x => x.CustomerID == id).FirstOrDefault(); } return(C); }
public List <Room> GetRooms() { var Lista = new List <Room>(); using (var db = new HotelCaliforniaEntities()) { Lista = (from R in db.Rooms select R).ToList(); } return(Lista); }
public void ChangeCustomer(Customer C) { using (var Data = new HotelCaliforniaEntities()) { var Item = Data.Customers.First(a => a.CustomerID == C.CustomerID); Item.FirstName = C.FirstName; Item.LastName = C.LastName; Item.PersonID = C.PersonID; Data.SaveChanges(); } }
public Booking GetBooking(int id) { var B = new Booking(); using (HotelCaliforniaEntities db = new HotelCaliforniaEntities()) { B = (from b in db.Bookings where b.BookingID == id select b).FirstOrDefault(); } return(B); }
public List <Booking> GetBookings(Customer C) { var Lista = new List <Booking>(); using (HotelCaliforniaEntities db = new HotelCaliforniaEntities()) { Lista = (from b in db.Bookings join c in db.Customers on b.CustomerID equals c.CustomerID where b.CustomerID == C.CustomerID select b).ToList(); } return(Lista); }
public bool CheckPersonID(Customer c) { var C = new List <Customer>(); using (HotelCaliforniaEntities db = new HotelCaliforniaEntities()) { C = db.Customers.Where(x => x.PersonID == c.PersonID && x.CustomerID != c.CustomerID).ToList(); } if (C.Count < 1) { return(false); } else { return(true); } }
public void CreateInvoice(Booking B) { var Get = new GetData(); Room R = Get.GetRoom(int.Parse(B.RoomID.ToString())); decimal Price = decimal.Parse(((B.DateEnd - B.DateStart).TotalDays * R.Price).ToString()); var I = new Invoice(); I.BookingID = B.BookingID; I.Complete = 0; I.BookedDate = DateTime.Now; I.TotalPrice = Price; using (var db = new HotelCaliforniaEntities()) { db.Invoices.Add(I); db.SaveChanges(); } }
public List <Customer> FindCustomer(string name) { using (HotelCaliforniaEntities db = new HotelCaliforniaEntities()) { List <Customer> Lista = new List <Customer>(); if (name.Length < 1) { Lista = (from c in db.Customers select c).ToList(); } else { Lista = (from c in db.Customers where c.FirstName.Contains(name) select c).ToList(); } return(Lista); } }
public void DeleteBooking(Booking B) { using (var db = new HotelCaliforniaEntities()) { var Item = db.Bookings.SingleOrDefault(x => x.BookingID == B.BookingID); db.Bookings.Remove(Item); var Invoice = db.Invoices.SingleOrDefault(x => x.BookingID == B.BookingID); if (Invoice == null) { db.SaveChanges(); } else { db.Invoices.Remove(Invoice); db.SaveChanges(); } } }