Esempio n. 1
0
        private async Task Login()
        {
            Enabled = false;
            try
            {
                var user = await _userDataService.LoginAsync(_user);

                LocalStorage.Add("UserRole", user.Role);
                LocalStorage.Add("Id", user.Id);

                if (user.Role == "ADMIN")
                {
                    await _navigationService.NavigateToAsync <HomeViewModel>();
                }
                else if (user.Role == "CUSTOMER" || user.Role == "CAFETARIA_EMPLOYEE")
                {
                    await _navigationService.NavigateToAsync <MenuViewModel>();
                }
            }
            catch (NotFoundException)
            {
                IsVisible    = true;
                ErrorMessage = "E-mailadres niet gevonden!";
                Enabled      = true;
            }
            catch (BadRequestException)
            {
                IsVisible    = true;
                ErrorMessage = "Foutief wachtwoord!";
                Enabled      = true;
            }
        }