Exemple #1
0
        public OperationResult Login(Login command)
        {
            var operationResult = new OperationResult();
            var Account         = _accountRepo.GetBy(command.UserName);

            if (Account == null)
            {
                return(operationResult.Failed(ApplicationMessage.WrongUserinformation));
            }

            var pass = PasswordHelper.EncodePasswordMd5(command.Password);

            if (pass != Account.Password)
            {
                return(operationResult.Failed(ApplicationMessage.WrongUserinformation));
            }


            var AuthViewModel = new AuthViewModel(Account.Id, Account.RoleId, Account.FullName, Account.Username);

            _authHelper.SingIn(AuthViewModel);

            return(operationResult.Succeeded());
        }