public AccountOpener(AccountCreatedEvent e, IBus bus) { this.bus = bus; this.accountCreatedEvent = e; this.correlationID = Guid.NewGuid(); this.response = AccountOpenerResponse.Pending; }
private void Apply(AccountCreatedEvent @event) { this.Id = @event.AggregateID; this.Name = @event.Name; this.Twitter = @event.Twitter; this.IsActive = @event.IsActive; }
private void OnAccountCreated(AccountCreatedEvent @event) { this.Id = @event.AggregateId; this.name = @event.Name; this.created = @event.Effective; this.balance = new List <Money>(@event.OpeningBalance); }
public void ShouldNot_AddNewProfile_Invalid() { var notificationEvent = new AccountCreatedEvent(); var newProfile = _manager.AddNewProfile(notificationEvent); Assert.Null(newProfile); }
private void Apply(AccountCreatedEvent @event) { Id = new AccountId(@event.Id); Name = @event.Name; Twitter = @event.Twitter; IsActive = @event.IsActive; }
public void Handle(AccountCreatedEvent <CustomUserAccount> evt) { if (evt.InitialPassword != null) { AddPasswordHistoryEntry(evt.Account.ID, evt.InitialPassword); } }
public BankAccount(Guid id, string name, Guid correlationId) : this() { //Pattern: Create the event and call ApplyEvent(Event) var accountCreated = new AccountCreatedEvent(id, CurrentVersion, correlationId, name); ApplyEvent(accountCreated); }
public virtual void Process(AccountCreatedEvent evt, object extra = null) { var data = GetExtraProperties(evt.Account, extra); data.Add("ConfirmChangeEmailUrl", AppInfo.AppUrl + AppInfo.ConfirmChangeEmailUrl + data["VerificationKey"]); Send(evt, evt.Account.Email, data); }
public async Task <AccountResponse> CreateAccountAsync(CreateAccountCommand createAccountCommand) { if (createAccountCommand == null) { throw new RequestNullException(); } AccountResponse accountResponse; bool alreadyExist = _dataContext.AccountModels.Any(m => m.Email == createAccountCommand.Email); if (alreadyExist) { throw new EmailAlreadyRegisteredException(createAccountCommand.Email); } await using (IDbContextTransaction transaction = _dataContext.Database.BeginTransaction(_integrationEventPublisher, autoCommit: true)) { var accountModel = new AccountModel(createAccountCommand.Email, createAccountCommand.FirstName, createAccountCommand.LastName); await _dataContext.AccountModels.AddAsync(accountModel); await _dataContext.SaveChangesAsync(); accountResponse = accountModel.ToAccountResponse(); var accountCreatedEvent = new AccountCreatedEvent(accountResponse); await _integrationEventPublisher.Publish(accountCreatedEvent); } return(accountResponse); }
public void PublishEvent() { // Arrange _event = new AccountCreatedEvent(); // Act SynchronousBus.Publish(_event); }
public void TestInitialise() { bus = new InProcessBus(); accountCreatedEvent = new AccountCreatedEvent(Guid.NewGuid(), 0, Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), false); sut = new AccountOpener(accountCreatedEvent, bus); bus.Subscribe(sut); AlarmClockService alarmClockService = new AlarmClockService(bus); }
public void ReplayEvent() { // Arrange _event = new AccountCreatedEvent(); // Act EventsReplayer.Replay(_event); }
public void Apply(AccountCreatedEvent @event) { ExternalId = @event.AccountDetails.Externalid; Balance = @event.AccountDetails.StartingBalance; CountryCode = @event.AccountDetails.CountryCode; CurrencyCode = @event.AccountDetails.CurrencyCode; AccountName = @event.AccountDetails.Name; }
public void Handle(AccountCreatedEvent message) { AggregateRoot.Active = false; AggregateRoot.Number = message.Number; AggregateRoot.ClientId = message.ClientId; AggregateRoot.ProductId = message.ProductId; AggregateRoot._operations = new OperationCollection(); }
public void That_should_be_handled_once() { var evt = new AccountCreatedEvent(); SynchronousBus.Publish(evt); // Assert Container.Resolve <MessageHandlerForHandleInProcessEventsAndHandleMessages>().HandledEvents.Single().Should().Be(evt); }
public void Handle(AccountCreatedEvent msg) { _modelBuilder.Add(new TransactionHistory { BalanceId = msg.BalanceId, EventType = typeof(AccountCreatedEvent).Name, Event = msg.ToPropsString(), Id = Guid.NewGuid(), Time = DateTimeFacade.Now }); }
public AccountAggregate(Guid id, string holderName, CorrelatedMessage source) : this() { var accountCreated = new AccountCreatedEvent(source) { HolderName = holderName, Id = id, State = "Active" }; Raise(accountCreated); }
public Task Handle(AccountCreatedEvent @event) { return(Task.Run(() => { _readRepository.Save(new BankAccountSummary { Id = @event.AggregateId, Name = @event.Name }); })); }
public void Handle(AccountCreatedEvent message) { state = message.State; holderName = message.HolderName; Accounts.Add(new Account { Id = message.Id.ToString(), HolderName = message.HolderName, State = message.State }); }
public Task CreateAccount(string name, decimal openingBalance) { var ev = new AccountCreatedEvent { AccountHolderName = name, EmployeeOpening = "Bruce Springsteen", OpeningBalance = openingBalance }; return(EventPipeline.AddEvent <CheckingAccount>(ev)); }
public void Handle(AccountCreatedEvent msg) { var businessCurrentBalance = new BusinessAccount { BalanceId = msg.BalanceId, BusinessId = msg.BusinessId }; _modelBuilder.Add(businessCurrentBalance); _publisher.Publish(new BusinessBalanceCreatedProjectedNotification(msg.BalanceId, msg)); }
public void Should_AddNewProfile_Valid() { var notificationEvent = new AccountCreatedEvent { ProfileId = "awesome", Id = Guid.NewGuid().ToString(), Version = 0 }; var newProfile = _manager.AddNewProfile(notificationEvent); Assert.NotNull(newProfile); }
public void Save_should_throws_when_aggregate_exist_for_expected_version_of([Frozen] Mock <IEventStorageProvider> eventStore, Repository repo, AccountCreatedEvent existingAccount, Guid aggregateId) { var aggregate = new BankAccount(aggregateId, "Joe Bloggs"); eventStore.Setup(x => x.GetLastEventAsync(It.Is <Type>(t => t == aggregate.GetType()), It.Is <Guid>(i => i == aggregateId))) .Returns(Task.FromResult <IEvent>(existingAccount)) .Verifiable(); Action act = () => repo.SaveAsync(aggregate).Wait(); act.ShouldThrow <AggregateException>() .WithInnerException <AggregateCreationException>(); }
public static void Seed() { var sessionFactory = CreateSessionFactory(); using (var session = sessionFactory.OpenSession()) { using (var transaction = session.BeginTransaction()) { var accountId = new Guid("9425cb8e-d836-483c-8749-f882a6b00011"); var evt = new AccountEvent { EventId = Guid.NewGuid(), AccountId = accountId }; var accountCreatedEvent = new AccountCreatedEvent() { Username = "******", Password = "******", DomainId = accountId, EventId = evt.EventId }; evt.Event = JsonConvert.SerializeObject(accountCreatedEvent); evt.EventType = typeof(AccountCreatedEvent).ToClassFullName(); evt.PublishDate = DateTime.Now; session.SaveOrUpdate(evt); evt = new AccountEvent { EventId = Guid.NewGuid(), AccountId = accountId }; var accountPasswordUpdatedEvnet = new AccountPasswordUpdatedEvnet() { Password = "******", DomainId = accountId, EventId = evt.EventId }; evt.Event = JsonConvert.SerializeObject(accountPasswordUpdatedEvnet); evt.EventType = typeof(AccountPasswordUpdatedEvnet).ToClassFullName(); evt.PublishDate = DateTime.Now.AddHours(1); session.SaveOrUpdate(evt); transaction.Commit(); } } }
public void Handle(AccountCreatedEvent @event) { var newAcc = this.accountDailyBalances.FirstOrDefault(o => o.AccountId == @event.AggregateId); if (newAcc == null) { newAcc = new AccountDailyBalance() { AccountId = @event.AggregateId, AccountName = @event.Name, Date = @event.DateOccured, Balance = new List <Money>(@event.OpeningBalance) }; this.accountDailyBalances.Add(newAcc); } else { throw new Exception(String.Format("Account already exists with Id: {0}", @event.AggregateId)); } }
public static async Task <AccountActivationOutput> ActivateAccountAsync <TAccount>( UserAccountService <TAccount> userAccountService, string verificationKey, string initialPassword) where TAccount : RelationalUserAccount { var output = new AccountActivationOutput(); var user = userAccountService.GetByVerificationKey(verificationKey); if (user == null) { output.UnknownUser = true; return(output); } //see if the verification key is not stale (expired). If so issue a reset pass command, that will fire an account created event with a new key, but without password (that should have been sent out on account create) if (userAccountService.IsVerificationKeyStale(user.ID)) { //in a case verification key is stale (outdated pretty much) need to trigger additional pass reset //and send some info to a user, so ne verification key can be provided AccountCreatedEvent <TAccount> e = null; userAccountService.Configuration.AddEventHandler(new MembershipRebootEventHandlers.AccountCreatedEventHandler <TAccount> ((evt) => { e = evt; }) ); userAccountService.ResetPassword(user.ID); //since got here the reset pass dod not fail and can add som data to output output.Email = user.Email; output.VerificationKey = e.VerificationKey; output.VerificationKeyStale = true; return(output); } else { userAccountService.VerifyEmailFromKey(verificationKey, initialPassword); output.Success = true; return(output); } }
public async Task Handle(AccountCreatedEvent notification, CancellationToken cancellationToken) { await AddAuditLogAsync("CreateAccount", notification.User, DateTime.Now, new[] { Mapper.Map <AccountRef>(notification.Account) }, null, new { Params = notification.Command }); }
private void Apply(AccountCreatedEvent e) { Id = e.BalanceId; OwnerId = e.BusinessId; }
private void OnDebitCardAccountCreated(AccountCreatedEvent cardAccountCreated) { }
public void Handle(AccountCreatedEvent evt) => Process(evt);
public void OnAccountCreated(AccountCreatedEvent evt) { Id = evt.AggregateRootId; }