protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
 {
     if (my_reservation == null)
     {
         my_reservation = PhoneHelpers.GetApplicationState<Reservation>("CurrentReservation");
         nameBox.Text = my_reservation.RestaurantName;
         DateBox.Text += my_reservation.StartTime.ToShortDateString();
         TimeBox.Text += my_reservation.StartTime.ToShortTimeString();
         // my_reservation.NumGuests.ToString();
     }
     base.OnNavigatedTo(e);
 }
 private void bothComplete()
 {
     textBlock1.Text += "Finding an open table\n";
     int Ti = 0, Ri = 0, bestIndex = -1, bestNum = 10000;
     Reservation sentinal = new Reservation();
     sentinal.TableID = 10000;
     this.ViewModel.rItems.Insert(ViewModel.rItems.Count, sentinal);
     while (Ti < this.ViewModel.tItems.Count && Ri < this.ViewModel.rItems.Count)
     {
         if (this.ViewModel.tItems[Ti].TableID > this.ViewModel.rItems[Ri].TableID)
         {
             Ri++;
         }
         else if (this.ViewModel.tItems[Ti].TableID < this.ViewModel.rItems[Ri].TableID)
         {
             //textBlock1.Text += "Open table found - " + this.ViewModel.tItems[Ti].TableID + "\n";
             if (this.ViewModel.tItems[Ti].NumSeats - this.ViewModel.Reservation.NumGuests < bestNum)
             {
                 bestIndex = Ti;
                 bestNum = (int)(this.ViewModel.tItems[Ti].NumSeats - this.ViewModel.Reservation.NumGuests);
                 if (bestNum == 0)
                     break;
             }
             Ti++;
         }
         else
         {
             Ti++;
             Ri++;
         }
     }
     this.ViewModel.rItems.RemoveAt(this.ViewModel.rItems.Count - 1); //remove sentinal
     if (bestIndex == -1)
     {
         textBlock1.Text += "No open tables found :(\nPlease go back and try again\n";
         PhoneHelpers.SetIsolatedStorageSetting("goBack", false);
         //appropriate action here
     }
     else
     {
         textBlock1.Text += "Best Table Available is " + this.ViewModel.tItems[bestIndex].TableID.ToString() + " numSeats: " + this.ViewModel.tItems[bestIndex].NumSeats.ToString() + "\n";
         //make reservation here
         this.ViewModel.Reservation.RestaurantName = this.ViewModel.RestName;
         this.ViewModel.Reservation.TableID = this.ViewModel.tItems[bestIndex].TableID;
         this.ViewModel.Reservation.ReservationID = 79;
         this.ViewModel.Reservation.CustomerID = PhoneHelpers.GetIsolatedStorageSetting<int>("reg_id");
         this.ViewModel.SetReservationModel();
         textBlock1.Text += "Booking Reservation\n";
         this.ViewModel.SaveChangesSuccess += new EventHandler(ViewModel_SaveChangesSuccess);
         this.ViewModel.SaveReservation();
     }
     this.ViewModel.IsListing = false;
 }
 private void submit_button_Click(object sender, RoutedEventArgs e)
 {
     //serviceClient.testService3Async("world!");
     //TODO: add something here
     Models.Reservation temp = new Reservation();
     temp.StartTime = ((DateTime)datePicker.Value).Date;
     temp.StartTime = temp.StartTime.AddHours(((DateTime)timePicker.Value).TimeOfDay.Hours);
     temp.StartTime = temp.StartTime.AddMinutes(((DateTime)timePicker.Value).TimeOfDay.Minutes);
     temp.EndTime = temp.StartTime;
     temp.EndTime = temp.EndTime.AddMinutes(45); //average reservation length could be defined by restaurant
     temp.RestaurantID = RestID;
     temp.NumGuests = Int32.Parse(guestsBox.Text);
     PhoneHelpers.SetApplicationState("CurrentReservation", temp);
     this.NavigationService.Navigate(new Uri("/Pages/ConfirmReservationPage.xaml?RestaurantID=" + RestID.ToString() + "&RestaurantName=" + RestName, UriKind.Relative));
 }
 public void AttachToReservations(Reservation reservation)
 {
     this.AttachTo("Reservations", reservation);
 }
 public void AddToReservations(Reservation reservation)
 {
     this.AddObject("Reservations", reservation);
 }