コード例 #1
0
        async void Login_Button_Clicked(object sender, EventArgs e)
        {
            ServerResponse response = await this.model.attemptLogin(this.email.Text, this.password.Text);

            if (!response.errorResponse.isOk)
            {
                await this.page.DisplayAlert("Sorry", response.errorResponse.message, "Ok");
            }

            LoginFetchObject login = response.loginObj;

            if (login != null)
            {
                App.Current.Properties["userId"] = login.userId;

                switch (login.userType)
                {
                case EModelUserType.student:
                    App.Current.Properties["usertype"] = 2;
                    App.Current.MainPage = new studentBaseTabPage(login.userId);
                    break;

                case EModelUserType.teacher:
                    App.Current.Properties["usertype"] = 1;
                    App.Current.MainPage = new NavigationPage(new TeacherPage(login.userId));
                    break;
                }
            }
        }
コード例 #2
0
        async void Go_Button_Clicked(object sender, EventArgs e)
        {
            int selectedIndex = this.type_Picker.SelectedIndex;

            if (selectedIndex == -1)
            {
                await this.page.DisplayAlert("", "You must select a user Type", "OK");
            }
            else
            {
                EModelUserType userType = EModelUserType.none;


                switch (selectedIndex)
                {
                case 0:
                    userType = EModelUserType.student;
                    break;

                case 1:
                    userType = EModelUserType.teacher;
                    break;
                }

                ServerResponse response = await this.model.createUser(this.name_Entry.Text, this.email_Entry.Text, this.password_Entry.Text, userType);

                if (!response.errorResponse.isOk)
                {
                    await this.page.DisplayAlert("Error", response.errorResponse.message, "OK");
                }

                LoginFetchObject login = response.loginObj;

                if (login != null)
                {
                    App.Current.Properties["userId"] = login.userId;

                    switch (login.userType)
                    {
                    case EModelUserType.student:
                        App.Current.Properties["usertype"] = 2;
                        App.Current.MainPage = new studentBaseTabPage(login.userId);
                        break;

                    case EModelUserType.teacher:
                        App.Current.Properties["usertype"] = 1;
                        App.Current.MainPage = new NavigationPage(new TeacherPage(login.userId));
                        break;
                    }
                }
            }
        }