internal offer GetAvailableOffer(DateTime selectedCheckIn, DateTime selectedCheckOut) { HotelEntities context = new HotelEntities(); offer aux = new offer(); bool foundOffer = false; foreach (var offer in context.offers.ToList()) { if (offer.startDate <= selectedCheckIn && offer.dueDate >= selectedCheckOut && (selectedCheckOut - selectedCheckIn).Days == offer.nrBookedRooms) { aux = offer; foundOffer = true; } } if (foundOffer == false) { foreach (var offer in context.offers.ToList()) { if (offer.id == 3) { aux = offer; } } } return(aux); }
internal void DeletePhoto(int idPoza) { HotelEntities context = new HotelEntities(); context.DeletePhoto(idPoza); context.SaveChanges(); }
public void Add(Client client) { var context = new HotelEntities(); context.Client.Add(client); context.SaveChanges(); }
public void DeleteGuest() { // Our stanard using statement passing all the data to context string name = FirstName + " " + LastName; if (MessageBox.Show("Do you REALLY want to delete " + name + "?", "Delete Record", MessageBoxButtons.YesNo) != DialogResult.Yes) { return; } try { using (var context = new HotelEntities()) { // Select the row you want to delete int id = GuestID; var guest = (from g in context.Guests where g.GuestID == id select g).SingleOrDefault(); // run remove command context.Guests.Remove(guest); // Save the changes context.SaveChanges(); } } catch (Exception e) { MessageBox.Show("Guest has already been deleted or another error has occured\n\n" + e); } }
public void AddPhoto(int id) { HotelEntities context = new HotelEntities(); Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.ShowDialog(); FileStream fs = new FileStream(dlg.FileName, FileMode.Open, FileAccess.Read); byte[] data = new byte[fs.Length]; fs.Read(data, 0, System.Convert.ToInt32(fs.Length)); fs.Close(); string iName = dlg.FileName; string folder = @"\Image\"; var path = Path.Combine(Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.FullName, Path.GetFileName(iName)); if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } context.AddPhoto(id, path); string currentFolder = Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.FullName; File.Copy(iName, path); }
public IEnumerable AllBookings() { using (var context = new HotelEntities()) { //var allbookings = _context.Bookings.OrderBy(b => b.BookingID) // .Where(b => b.GuestIDFK == b.Guest.GuestID) // .Where(b => b.RoomIDFK == b.Room.RoomID) // .Select(b => b.BookingID); //.Select(b => b.RoomIDFK); //b => b.Room.RoomName, b => b.GuestIDFK, // b => b.Guest.FullName, b => b.NumOfGuests, b => b.CheckIn, b => b.CheckOut); //where //return allbookings.ToList(); //var allGuests = _context.Guests.OrderBy(r => r.LastName); //return allGuests.ToList(); var alldata = from b in context.Bookings where b.GuestIDFK == b.Guest.GuestID && b.RoomIDFK == b.Room.RoomID orderby b.RoomIDFK select new { b.BookingID, b.RoomIDFK, b.Room.RoomName, b.GuestIDFK, b.Guest.FullName, b.NumOfGuests, b.CheckIn, b.CheckOut }; return(alldata.ToList()); } }
public void DeleteRoomType() { // Our stanard using statement passing all the data to context string roomtype = Room_Type; if (MessageBox.Show("Do you REALLY want to delete " + roomtype + "?", "Delete Record", MessageBoxButtons.YesNo) != DialogResult.Yes) { return; } try { using (var context = new HotelEntities()) { // Select the row you want to delete int id = RoomTypeID; var roomType = (from rt in context.RoomTypes where rt.RoomTypeID == id select rt).SingleOrDefault(); // run remove command context.RoomTypes.Remove(roomType); // Save the changes context.SaveChanges(); } } catch (Exception e) { MessageBox.Show("Room Type has already been deleted or another error has occured\n\n" + e); } }
public void NewBooking() { //try //{ using (var context = new HotelEntities()) { var b = new Booking(); b.GuestIDFK = GuestID; b.RoomIDFK = RoomID; b.NumOfGuests = NumOfGuests; b.CheckIn = CheckIn; b.CheckOut = CheckOut; context.Bookings.Add(b); context.SaveChanges(); //var BookedConfirmationMessage = Environment.NewLine + "You have booked Room " + b.RoomIDFK + // Environment.NewLine + "From " + b.CheckIn + " to " + b.CheckOut + // Environment.NewLine + "For " + // (string.Format("{0:C}", Cost) + " X " + TotalDays + " = " + TotalCost); ////Show a confirmation message //MessageBox.Show(BookedConfirmationMessage); } //} //catch (Exception e) //{ // MessageBox.Show(e.ToString()); //} }
public void LogIn(string name, string password) { HotelEntities context = new HotelEntities(); var conturi = context.accounts.ToList(); bool contExistent = false; foreach (var cont in conturi) { if (cont.email == name) { if (cont.pass == password) { MessageBox.Show("Bun venit!"); MainViewModel.Instance.ActiveScreen = new BookingsViewModel(cont); } else { MessageBox.Show("Parola gresita!"); } contExistent = true; } } if (contExistent == false) { MessageBox.Show("Cont inexistent!"); } }
public void Delete(int id, account cont) { HotelEntities context = new HotelEntities(); context.RemoveRooms(id); MainViewModel.Instance.ActiveScreen = new RoomsViewModel(cont); }
public void Search(object param) { var context = new HotelEntities(); var list = new List <Camera>(); foreach (var camera in context.Camera) { bool nerezervata = true; foreach (var rezervare in camera.Rezervare) { if (rezervare.StartDate >= viewModel.startDateTime && rezervare.EndDate <= viewModel.endDateTime) { nerezervata = false; break; } } if (nerezervata) { var room = new Room() { Id = camera.Id_Camera, Price = camera.Price, Type = camera.Type }; viewModel.RoomList.Add(room); list.Add(camera); } } foreach (var camera in list) { foreach (var oferta in camera.Oferta) { viewModel.DiscountList.Add(new Discount() { Id = oferta.Id_Oferta, Type = oferta.Type, Value = oferta.Value, StartDate = oferta.StartDate, EndDate = oferta.EndDate }); } } foreach (var service in context.ServiciiSuplimentare) { viewModel.ExtraServicesList.Add(new ExtraService() { Id = service.Id_ServiciiSuplimentare, Price = service.Price, Type = service.Type }); } var allRes = context.Rezervare.Where(i => i.Id_Client == DataManager.Instance.CurrentUser.Id_Client); foreach (var res in allRes) { viewModel.ReservationList.Add(res); } }
public void Modify(int id, string featureName, string price, account cont) { HotelEntities context = new HotelEntities(); context.ModifyService(id, featureName, int.Parse(price)); context.SaveChanges(); MainViewModel.Instance.ActiveScreen = new ServicesViewModel(cont); }
public void Save(string serviceName, string price, account cont) { HotelEntities context = new HotelEntities(); context.AddService(serviceName, int.Parse(price)); context.SaveChanges(); MainViewModel.Instance.ActiveScreen = new ServicesViewModel(cont); }
internal void DeleteAccount(int id, account _cont) { HotelEntities context = new HotelEntities(); context.RemoveAccount(id); context.SaveChanges(); MainViewModel.Instance.ActiveScreen = new AccountsViewModel(_cont); }
public void Save(string featureName) { HotelEntities context = new HotelEntities(); context.AddFeature(featureName); context.SaveChanges(); MainViewModel.Instance.ActiveScreen = new FeaturesViewModel(); }
internal void DeleteOffer(int id, account cont) { HotelEntities context = new HotelEntities(); context.RemoveOffers(id); context.SaveChanges(); MainViewModel.Instance.ActiveScreen = new OffersViewModel(cont); }
public void Modify(int id, string featureName) { HotelEntities context = new HotelEntities(); context.ModifyFeature(id, featureName); context.SaveChanges(); MainViewModel.Instance.ActiveScreen = new FeaturesViewModel(); }
public void Delete(int id) { HotelEntities context = new HotelEntities(); context.RemoveFeatures(id); context.SaveChanges(); MainViewModel.Instance.ActiveScreen = new FeaturesViewModel(); }
public void DeleteBooking(int id, account _cont) { HotelEntities context = new HotelEntities(); context.RemoveBooking(id); context.SaveChanges(); MainViewModel.Instance.ActiveScreen = new BookingsViewModel(_cont); }
internal void PayBooking(int id, account cont) { HotelEntities context = new HotelEntities(); context.PayBooking(id); context.SaveChanges(); MainViewModel.Instance.ActiveScreen = new BookingsViewModel(cont); }
public void Send(ReservationBE rBE) { try { HotelEntities hotel = new HotelEntities(); Reservation reservation = new Reservation(); Customer customer = new Customer(); var idR = (from r in hotel.Reservation where r.CustomerId == rBE.CustomerId && r.HotelId == rBE.HotelId && r.RoomId == rBE.RoomId select r).FirstOrDefault(); var res = (from r in hotel.Reservation join c in hotel.Customer on r.CustomerId equals c.id join u in hotel.Room on r.RoomId equals u.id join h in hotel.Hotel on r.HotelId equals h.id where r.id == idR.id select new ReservationBE { Id = r.id, CustomerId = c.Phone, CustomerName = c.Name + " " + c.SurName, HotelId = r.HotelId, HotelName = h.Name, RoomId = u.id, RoomName = u.TypeRoom, AdmissionDate = r.AdmissionDate, DepartureDate = r.DepartureDate, }).FirstOrDefault(); //var cus = (from c in hotel.Customer where c.id == idR.CustomerId select c).FirstOrDefault(); var client = new Client(creds: new Nexmo.Api.Request.Credentials { ApiKey = "5c071953", ApiSecret = "9B1hZUpUzBzplHUF" }); var results = client.SMS.Send(request: new SMS.SMSRequest { from = "Nexmo", // Se Agrego a CustomerId el Numero del cliente. to = "51" + res.CustomerId, text = "Sr/Sra " + res.CustomerName + " su reserva en " + res.HotelName + " habitacion " + res.RoomName + " de " + res.AdmissionDate + "a" + res.DepartureDate }); } catch (Exception e) { throw new Exception(e.Message); } }
private void btnSubmit_Click(object sender, RoutedEventArgs e) { GetOwnerCredentials(); if (txtUsername.Text == _ownerUsername && txtPassword.Password == _ownerPassword) { _logged = true; OwnerView view = new OwnerView(); view.ShowDialog(); } else { List <IUser> allusers = new List <IUser>(); try { using (HotelEntities db = new HotelEntities()) { foreach (tblManager manager in db.tblManagers) { allusers.Add(manager as IUser); } foreach (tblStaff staff in db.tblStaffs) { allusers.Add(staff as IUser); } } foreach (IUser user in allusers) { if (user.Username == txtUsername.Text && user.HashedPassword == txtPassword.Password) { if (user is tblManager) { _logged = true; ManagerView view = new ManagerView(); view.ShowDialog(); break; } else { _logged = true; StaffView view = new StaffView(); view.ShowDialog(); break; } } } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } } if (_logged == false) { MessageBox.Show("Username or Password Not Valid"); } }
internal tblEmployee GetEmployee(string userName) { using (HotelEntities context = new HotelEntities()) { tblAccount account = (from a in context.tblAccounts where a.UserName == userName select a).First(); tblEmployee employee = (from e in context.tblEmployees where e.AccountID == account.AccountID select e).First(); return(employee); } }
internal tblManager GetManager(string userName) { using (HotelEntities context = new HotelEntities()) { tblAccount account = (from a in context.tblAccounts where a.UserName == userName select a).First(); tblManager manager = (from m in context.tblManagers where m.AccountID == account.AccountID select m).First(); return(manager); } }
public void Delete(int id) { var context = new HotelEntities(); var services = context.ServiciiSuplimentare.First(i => i.Id_ServiciiSuplimentare == id); services.Deleted = true; context.SaveChanges(); }
public void Delete(int id) { var context = new HotelEntities(); var discount = context.Oferta.First(i => i.Id_Oferta == id); discount.Deleted = true; context.SaveChanges(); }
public void Delete(int id) { var context = new HotelEntities(); var feature = context.Dotare.First(i => i.Id_Dotare == id); feature.Deleted = true; context.SaveChanges(); }
public void Update(ExtraService service) { var context = new HotelEntities(); var oldService = context.ServiciiSuplimentare.First(i => i.Id_ServiciiSuplimentare == service.Id); oldService.Price = service.Price; oldService.Type = service.Type; context.SaveChanges(); }
public void Update(Feature feature) { var context = new HotelEntities(); var oldFeature = context.Dotare.First(i => i.Id_Dotare == feature.Id); oldFeature.Price = feature.Price; oldFeature.Type = feature.Type; context.SaveChanges(); }
public ObservableCollection <feature> GetFeatures() { HotelEntities context = new HotelEntities(); ObservableCollection <feature> auxList = new ObservableCollection <feature>(); foreach (var feature in context.features.ToList()) { auxList.Add(feature); } return(auxList); }
public HotelRepository() { hotelContext = new HotelEntities(); }
public MakeReservation() { _flight = new FlightEntities(); _hotel = new HotelEntities(); }