Ejemplo n.º 1
0
        public async Task<ObservableCollection<Journey>> RetrieveJourneys (string fromDate, string toDate, string destination)
        {
            _journeys.Clear();
            
            RestServices rs = new RestServices();
            ObservableCollection<Journey> journeys = await rs.JourneysSearch(fromDate, toDate, destination);

            foreach (var item in journeys)
            {
                if (_journeys.IndexOf(item) < 0)
                {
                    _journeys.Add(item);
                }
            }
            return _journeys;
        }
        private async void BookButton_Click(object sender, RoutedEventArgs e)
        {
            MyProgressRing.IsEnabled = true;
            MyProgressRing.IsActive = true;
            MyProgressRing.Visibility = Windows.UI.Xaml.Visibility.Visible;
            
            var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
            
            MessageDialog messageDialog = null;
            bool exceptionOccurred = false;

            try
            {
                RestServices rs = new RestServices();
                if (await rs.BookingService(_bookingContext.Amount, _bookingContext.CardNumber, _bookingContext.ID))
                {
                    messageDialog = new MessageDialog(loader.GetString("TripBookedSucceededDescription_1") + _bookingContext.Destination + loader.GetString("TripBookedSucceededDescription_2") + _bookingContext.Amount, loader.GetString("TripBookedSucceededMessage"));
                }
                else
                {
                    messageDialog = new MessageDialog(loader.GetString("TripNotBookedDescription"), loader.GetString("TripNotBookedMessage"));
                }
                messageDialog.Commands.Add(new UICommand(loader.GetString("OKMessage")));
            }
            catch
            {
                exceptionOccurred = true;
            }

            if (exceptionOccurred){
                messageDialog = new MessageDialog(loader.GetString("TripNotBookedDescription"), loader.GetString("TripNotBookedMessage"));
                messageDialog.Commands.Add(new UICommand(loader.GetString("OKMessage")));
            }

            await messageDialog.ShowAsync();

            MyProgressRing.IsEnabled = false;
            MyProgressRing.IsActive = false;
            MyProgressRing.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
        }
Ejemplo n.º 3
0
        private async void tripDestinationSuggestionBox_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
        {
            if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput) {
                string textInput = tripDestinationSuggestionBox.Text.ToString();
                if (textInput.Length > 0)
                {
                    bool exceptionOccurred = false;
                    try
                    {
                        RestServices rs = new RestServices();
                        sender.ItemsSource = await rs.DestinationsSearch(CheckForJourneys, MaxSize, textInput);
                        searchButton.IsEnabled = true;
                    }
                    catch
                    {
                        exceptionOccurred = true;
                        searchButton.IsEnabled = false;
                    }

                    if (exceptionOccurred)
                    {
                        var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
                        MessageDialog exceptionMessageDialog = new MessageDialog(loader.GetString("CheckYourNetworkSettingsAndStatusMessage"), loader.GetString("ConnectionFailureMessage"));
                        exceptionMessageDialog.Commands.Add(new UICommand(loader.GetString("OKMessage")));
                        await exceptionMessageDialog.ShowAsync();
                    }
                }
                else
                {
                    sender.ItemsSource = new string[] { };
                    searchButton.IsEnabled = false;
                }
            }
        }
Ejemplo n.º 4
0
        private async void Login_Button_Click(object sender, RoutedEventArgs e)
        {
            MyProgressRing.IsEnabled = true;
            MyProgressRing.IsActive = true;
            MyProgressRing.Visibility = Windows.UI.Xaml.Visibility.Visible;

            var loader = new Windows.ApplicationModel.Resources.ResourceLoader();

            try
            {
                RestServices rs = new RestServices();
                if (await rs.LoginService(userTextBox.Text, passwordTextBox.Password))
                {
                    resultTextBlock.Text = loader.GetString("LoginSucceededMessage");
                    _loggedInUser = userTextBox.Text;
                }
                else
                {
                    resultTextBlock.Text = loader.GetString("LoginFailedMessage");
                    _loggedInUser = null;
                }
            }
            catch
            {
                resultTextBlock.Text = loader.GetString("ConnectionFailureMessage");
            }

            resultTextBlock.Visibility = Windows.UI.Xaml.Visibility.Visible;
            MyProgressRing.IsEnabled = false;
            MyProgressRing.IsActive = false;
            MyProgressRing.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
        }