private async void ExecuteLoginCommand()
        {
            User user = await UserRepositoryAsync.GetAsync(_email, _password);

            if (user == null)
            {
                _isValidLogin = false;
                OnPropertyChanged(nameof(IsValidLogin));
                return;
                //invalid credentials make error message visible
            }

            //Login user
            UserSessionManager.LoginUser(user, _navigationService);
        }
Exemplo n.º 2
0
        private async void ExecuteRegisterUserCommand()
        {
            //Register a new user (buyer or seller) in the database
            var user = new User
            {
                Name        = Name,
                Email       = Email,
                Password    = Password,
                DateCreated = DateTime.Now,
                UserTypeId  = _isSeller ? (int)UserTypeEnum.Seller : (int)UserTypeEnum.Buyer
            };

            int saved = await UserRepositoryAsync.SaveAsync(user);

            if (saved <= 0)
            {
                return;             //TODO: Show error message
            }
            User dbUser = await UserRepositoryAsync.GetAsync(user.Email, user.Password);

            //Login user
            UserSessionManager.LoginUser(dbUser, _navigationService);
        }