예제 #1
0
        private async void BtnLogin_Click(object sender, RoutedEventArgs e)
        {
            progressBar.Visibility = Visibility.Visible;
            var user = new UserAuthDto
            {
                Phone    = txtPhone.Text,
                Password = txtPassword.Password
            };

            try
            {
                var response = await _httpClientService.AuthenticateUser(user);

                var responseJson = JsonConvert.SerializeObject(response);
                if (response != null)
                {
                    switch (response.Role)
                    {
                    case Core.Enumerations.EnumRole.Administrator:
                        this.Frame.Navigate(typeof(DashboardPage), responseJson);
                        break;

                    case Core.Enumerations.EnumRole.Driver:
                        this.Frame.Navigate(typeof(DriversDashboardPage), responseJson);
                        break;
                    }
                    var firstItem = this.Frame.BackStack.Distinct().ToList().First();
                    Frame.BackStack.Remove(firstItem);
                }
                else
                {
                    txtError.Text = "An error occured, check your connection or credentials";
                }
            }
            catch (Exception ex)
            {
                txtError.Text = ex.Message;
            }
            progressBar.Visibility = Visibility.Collapsed;
        }
예제 #2
0
        public IActionResult AuthenticateUser(string username, string password)
        {
            ResponseTokenModel response = _httpClientService.AuthenticateUser(username: username, password: password);

            return(Ok(response));
        }