private Configuration()
        {
            _bus = new MessageBus();
            var eventStore = new SqlEventStore(_bus);
            var repository = new DomainRepository(eventStore);

            var commandService = new AccountApplicationService(repository);
            _bus.RegisterHandler<RegisterAccountCommand>(commandService.Handle);
            _bus.RegisterHandler<DebitAccountCommand>(commandService.Handle);
            _bus.RegisterHandler<UnlockAccountCommand>(commandService.Handle);

            var infoProjection = new AccountInfoProjection();
            _bus.RegisterHandler<AccountRegisteredEvent>(infoProjection.Handle);
            _bus.RegisterHandler<AccountLockedEvent>(infoProjection.Handle);
            _bus.RegisterHandler<AccountUnlockedEvent>(infoProjection.Handle);

            var balanceProjection = new AccountBalanceProjection();
            _bus.RegisterHandler<AccountRegisteredEvent>(balanceProjection.Handle);
            _bus.RegisterHandler<AccountDebitedEvent>(balanceProjection.Handle);

            var notification = new NotificationProjection();
            _bus.RegisterHandler<AccountRegisteredEvent>(notification.Handle);
            _bus.RegisterHandler<AccountDebitedEvent>(notification.Handle);
            _bus.RegisterHandler<AccountLockedEvent>(notification.Handle);
            _bus.RegisterHandler<AccountUnlockedEvent>(notification.Handle);
            _bus.RegisterHandler<OverdrawAttemptedEvent>(notification.Handle);

            _readModel = new ReadModelFacade(balanceProjection, infoProjection, notification);

            var events = eventStore.GetAllEventsEver();
            _bus.Publish(events);
        }
Example #2
0
        public AccountApplicationServiceTests()
        {
            _mockOfUserDomainService   = new Mock <IUserDomainService>();
            _mockOfUserRepository      = new Mock <IUserRepository>();
            _mockOfTokenDomainService  = new Mock <ITokenDomainService>();
            _mockOfUserPhoneRepository = new Mock <IUserPhoneRepository>();

            _service = new AccountApplicationService(_mockOfUserDomainService.Object, _mockOfTokenDomainService.Object, _mockOfUserRepository.Object, _mockOfUserPhoneRepository.Object);
        }
Example #3
0
 public AccountCreateUserTest()
 {
     _uow = new Mock <IUserUnitOfWork>()
     {
         CallBase = true
     };
     _accountCreateValidation = new AccountCreateValidation(_uow.Object);
     _accountValidation       = new AccountValidation(_accountCreateValidation);
     _app = new Mock <AccountApplicationService>(_uow.Object, _accountValidation)
     {
         CallBase = true
     }.Object;
 }
Example #4
0
        public JsonResult Login(string UserName, string Password, string Code, SysUserMaintenanceDTO sysUserMaintenanceDTO)
        {
            if (Session["Code"] == null)
            {
                return(Json(JsonHandler.CreateMessage(0, "请重新刷新验证码"), JsonRequestBehavior.AllowGet));
            }

            if (Session["Code"].ToString().ToLower() != Code.ToLower())
            {
                return(Json(JsonHandler.CreateMessage(0, "验证码错误"), JsonRequestBehavior.AllowGet));
            }

            TransactionalInformation transaction;
            //AccountViewModel accountViewModel = new AccountViewModel();
            AccountApplicationService accountApplicationService = new AccountApplicationService(accountDataService);

            SysUser user = accountApplicationService.Login(UserName, ValueConvert.MD5(Password), out transaction);

            //accountViewModel.SysUser = user;
            //accountViewModel.ReturnStatus = transaction.ReturnStatus;
            //accountViewModel.ReturnMessage = transaction.ReturnMessage;

            //if (accountViewModel.ReturnStatus == true)
            //{
            //    //return Json(JsonHandler.CreateMessage(0, accountViewModel.ReturnStatus.ToString()), JsonRequestBehavior.AllowGet);
            //    return Json(JsonHandler.CreateMessage(0, user.State.ToString()), JsonRequestBehavior.AllowGet);
            //}


            if (user == null)
            {
                return(Json(JsonHandler.CreateMessage(0, "用户名或密码错误"), JsonRequestBehavior.AllowGet));
            }
            else if (!Convert.ToBoolean(user.State))//被禁用
            {
                return(Json(JsonHandler.CreateMessage(0, "账户被系统禁用"), JsonRequestBehavior.AllowGet));
            }


            Account account = new Account();

            account.Id         = user.Id;
            account.TrueName   = user.TrueName;
            Session["Account"] = account;

            return(Json(JsonHandler.CreateMessage(1, ""), JsonRequestBehavior.AllowGet));
        }
        private Configuration()
        {
            _bus = new MessageBus();
            var eventStore = new SqlEventStore(_bus);
            var repository = new DomainRepository(eventStore);

            var commandService = new AccountApplicationService(repository);

            _bus.RegisterHandler <RegisterAccountCommand>(commandService.Handle);
            _bus.RegisterHandler <DebitAccountCommand>(commandService.Handle);
            _bus.RegisterHandler <UnlockAccountCommand>(commandService.Handle);

            var infoProjection = new AccountInfoProjection();

            _bus.RegisterHandler <AccountRegisteredEvent>(infoProjection.Handle);
            _bus.RegisterHandler <AccountLockedEvent>(infoProjection.Handle);
            _bus.RegisterHandler <AccountUnlockedEvent>(infoProjection.Handle);

            var balanceProjection = new AccountBalanceProjection();

            _bus.RegisterHandler <AccountRegisteredEvent>(balanceProjection.Handle);
            _bus.RegisterHandler <AccountDebitedEvent>(balanceProjection.Handle);

            var notification = new NotificationProjection();

            _bus.RegisterHandler <AccountRegisteredEvent>(notification.Handle);
            _bus.RegisterHandler <AccountDebitedEvent>(notification.Handle);
            _bus.RegisterHandler <AccountLockedEvent>(notification.Handle);
            _bus.RegisterHandler <AccountUnlockedEvent>(notification.Handle);
            _bus.RegisterHandler <OverdrawAttemptedEvent>(notification.Handle);

            _readModel = new ReadModelFacade(balanceProjection, infoProjection, notification);

            var events = eventStore.GetAllEventsEver();

            _bus.Publish(events);
        }
 public override void RegisterHandler(MessageBus bus, IRepository repo)
 {
     var svc = new AccountApplicationService(repo);
     bus.RegisterHandler<DebitAccountCommand>(svc.Handle);
 }
Example #7
0
 public AccountController(AccountApplicationService applicationService)
 {
     _applicationService = applicationService;
 }
Example #8
0
        public override void RegisterHandler(MessageBus bus, IRepository repo)
        {
            var svc = new AccountApplicationService(repo);

            bus.RegisterHandler <DebitAccountCommand>(svc.Handle);
        }