Exemplo n.º 1
0
        private async void BtnLogin_OnClick(object sender, RoutedEventArgs e)
        {
            Member member = new Member();

            member.email    = txtEmail.Text;
            member.password = txtPassword.Password;

            var content = ApiHandle.Login(member);

            if (content.Result.IsSuccessStatusCode)
            {
                txtError.Foreground = new SolidColorBrush(Colors.Green);
                txtError.Text       = "Login Success!!!!!";
                await Task.Delay(1000);

                CurrentUser.currentUser = await ApiHandle.GetCurUser(member.email);

                Debug.WriteLine(CurrentUser.currentUser.address);
                if (CurrentUser.currentUser.Role_id == 1)
                {
                    var rootFrame = Window.Current.Content as Frame;
                    rootFrame.Navigate(typeof(TravellerBoard));
                }
                else if (CurrentUser.currentUser.Role_id == 2)
                {
                    var rootFrame = Window.Current.Content as Frame;
                    rootFrame.Navigate(typeof(GuideBoard));
                }
            }
            else
            {
                txtError.Foreground = new SolidColorBrush(Colors.Red);
                txtError.Text       = "Login Faild!!!!";
            }
        }