Пример #1
0
        public HangerdResult<bool> Register(string loginName, string password)
        {
            return Try(() =>
            {
                using (var context = UnitOfWorkManager.Begin<IRepositoryContext>())
                using (var eventBus = UnitOfWorkManager.Begin<IEventBus>())
                {
                    var spec = AccountSpecifications.LoginNameEquals(loginName);
                    var existAccount = _accountRepository.Get(spec, false);

                    if (existAccount != null)
                        throw new HangerdException("账号已存在");

                    var account = new Account(loginName, password);

                    _accountRepository.Add(account);

                    context.Commit();
                    eventBus.Commit();
                }
            }, "注册成功");
        }
Пример #2
0
 public AccountCreatedEvent(Account account)
 {
     Account = account;
 }