Exemplo n.º 1
0
        public async Task <ActionResult> Login(AccountViewModel pAcctViewModel)
        {
            if (ModelState.IsValid)
            {
                var success = await _apiHelper.VerifyLogin(pAcctViewModel.LoginName, pAcctViewModel.Password);

                if (success)
                {
                    _peopleViewModel.LoggedInEmailAddress = pAcctViewModel.LoginName;

                    //TODO: need to revisit later to get user Id more efficiently
                    var userList = await _userEndPoint.GetAll();

                    foreach (var user in userList)
                    {
                        if (user.EmailAddress.Equals(_peopleViewModel.LoggedInEmailAddress))
                        {
                            _peopleViewModel.LoggedInUserId    = user.Id;
                            _peopleViewModel.LoggedInFirstName = user.FirstName;
                            _peopleViewModel.LoggedInLastName  = user.LastName;
                            break;
                        }
                    }

                    return(RedirectToRoute("Main"));
                }
            }

            return(View("Index"));
        }
        private async Task LoadUsers()
        {
            var userList = await _userEndPoint.GetAll();

            Users = new BindingList <UserModel>(userList);
        }