Esempio n. 1
0
        async void OnVerify()
        {
            if (code.Text != null)
            {
                newUser.function = "confirmRegister";
                newUser.code     = code.Text;
                object obj = SynchronousSocketClient.StartClient("confirmRegister", newUser);
                newUser = (NewUser)obj;
                if (newUser.response.Equals("success", StringComparison.OrdinalIgnoreCase))
                {
                    DependencyService.Get <IMessage>().ShortAlert("Server says: " + newUser.response);
                    await this.DisplayAlert("Register", "Your e-mail has been succesfully verified. You can log in now.", "Go to login");

                    await Navigation.PopToRootAsync();
                }
                else
                {
                    DependencyService.Get <IMessage>().ShortAlert("Server says: " + newUser.response);
                }
            }
            else
            {
                DependencyService.Get <IMessage>().ShortAlert("Verification code can NOT be empty.");
            }
        }
Esempio n. 2
0
        async void OnLogin(object sender, EventArgs e)
        {
            //await Navigation.PushAsync(new MainPage()); //quick override of login in case server is down, can't interact with the server even if it comes online meanwhile. FOR TESTING ONLY!
            counter = 0;
            if (username.Text != null || password.Text != null)
            {
                client          = new User(username.Text, Core.LoginSystem.CalculateMD5Hash(password.Text));
                client.function = "login";
            }
            else
            {
                client = new User("user", "pass");
            }
            object obj = SynchronousSocketClient.StartClient("login", client);

            client = (User)obj;
            App.Current.Properties["sessionKey"] = client.sessionKey;
            App.Current.Properties["user"]       = client.username;
            if (!client.sessionKey.Equals("invalid") && !client.sessionKey.Equals("") && !client.sessionKey.Equals(null) && client.sessionKey.Length == 32)
            {
                await this.DisplayAlert("Login", "User " + client.username + " logged in.", "Continue");

                await Navigation.PushAsync(new MainPage());

                Navigation.RemovePage(this);
            }
            else
            {
                await this.DisplayAlert("Login", "Make sure you entered correct credentials and that you are connected to the internet.", "Continue");
            }
        }
Esempio n. 3
0
        /// <summary>
        /// This method gathers all the necessary data to make an order of a taxi and directs the user to the confirm page.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnOrder(object sender, EventArgs e)
        {
            Ride   ride;
            string sessionKey = Convert.ToString(App.Current.Properties["sessionKey"]);

            ride          = new Ride(fromLatitude, fromLongitude, toLatitude, toLongitude, sessionKey);
            ride.function = "getDistanceTimePrice";
            object obj = SynchronousSocketClient.StartClient("getDistanceTimePrice", ride);

            ride = (Ride)obj;
            Console.WriteLine("Response: " + ride.response);
            RideDetails details = JsonConvert.DeserializeObject <RideDetails>(ride.response);
            TempData    data    = new TempData()
            {
                sessionKey  = sessionKey,
                distance    = details.distance,
                time        = details.time,
                price       = details.price,
                startLoc    = details.start,
                destination = details.destination,
                fromLat     = fromLatitude,
                fromLng     = fromLongitude,
                toLat       = toLatitude,
                toLng       = toLongitude
            };

            SQLite.CreateDatabase();
            SQLite.InsertTempData(data);
            Navigation.PushAsync(new ConfirmPage());
        }
Esempio n. 4
0
        void OnTest(object sender, EventArgs e)
        {
            bool test = SynchronousSocketClient.TestConnection();

            if (test)
            {
                DependencyService.Get <IMessage>().ShortAlert("Connection established.");
            }
            else
            {
                DependencyService.Get <IMessage>().ShortAlert("Connection NOT established.");
            }
        }
        async void OnRegister(object sender, EventArgs e)
        {
            if (email.Text != null)
            {
                if (username.Text != null)
                {
                    if (password.Text != null)
                    {
                        if (firstname.Text != null)
                        {
                            if (lastname.Text != null)
                            {
                                if (password.Text.Equals(confirmpassword.Text))
                                {
                                    NewUser newUser = new NewUser(email.Text, username.Text, Core.LoginSystem.CalculateMD5Hash(password.Text), firstname.Text, lastname.Text, cartype.SelectedIndex + 1);
                                    newUser.function = "register";
                                    App.Current.Properties["username"] = newUser.username;
                                    App.Current.Properties["password"] = newUser.password;
                                    object obj = SynchronousSocketClient.StartClient("register", newUser);
                                    newUser = (NewUser)obj;
                                    if (newUser.response.Equals("success", StringComparison.OrdinalIgnoreCase))
                                    {
                                        DependencyService.Get <IMessage>().ShortAlert("Server says: " + newUser.response);
                                        await this.DisplayAlert("Register", "We have sent you an e-mail with a verification code to " + newUser.email +
                                                                ". You will be prompted to enter said code next.", "OK");

                                        //await Navigation.PopAsync();
                                        await Navigation.PushAsync(new VerificationPage(newUser));
                                    }
                                    else
                                    {
                                        DependencyService.Get <IMessage>().ShortAlert("Server says: " + newUser.response);
                                    }
                                }
                                else
                                {
                                    DependencyService.Get <IMessage>().ShortAlert("Please make sure your passwords match.");
                                }
                            }
                            else
                            {
                                DependencyService.Get <IMessage>().ShortAlert("Please enter your last name.");
                            }
                        }
                        else
                        {
                            DependencyService.Get <IMessage>().ShortAlert("Please enter your first name.");
                        }
                    }
                    else
                    {
                        DependencyService.Get <IMessage>().ShortAlert("Please enter a password.");
                    }
                }
                else
                {
                    DependencyService.Get <IMessage>().ShortAlert("Please enter a username.");
                }
            }
            else
            {
                DependencyService.Get <IMessage>().ShortAlert("Please enter your e-mail.");
            }
        }