예제 #1
0
        public HangerdResult <AccountDto> GetAccountForLogin(string loginName, string password)
        {
            return(Try(() =>
            {
                using (UnitOfWorkManager.Begin <IRepositoryContext>())
                {
                    if (string.IsNullOrWhiteSpace(loginName) || string.IsNullOrWhiteSpace(password))
                    {
                        throw new HangerdException("用户名或密码为空");
                    }

                    var spec = DeletableSpecifications <Account> .NotDeleted() & AccountSpecifications.LoginNameEquals(loginName);
                    var account = _accountRepository.Get(spec, false);

                    Requires.NotNull(account, "用户名不存在");

                    if (!account.ValidatePassword(password))
                    {
                        throw new HangerdException("密码错误");
                    }

                    return Mapper.Map <Account, AccountDto>(account);
                }
            }, "登录成功"));
        }
예제 #2
0
        public bool ExistLoginName(string loginName)
        {
            var spec = DeletableSpecifications <Account> .NotDeleted() & AccountSpecifications.LoginNameEquals(loginName);

            return(GetAll(spec, false).Any());
        }