public DepositMoney(OId <BankAccount, Guid> bankAccountId, Transaction transaction, Money amount, TimeStamp timeStamp) : base(timeStamp) { BankAccountId = bankAccountId; Transaction = transaction; Amount = amount; }
public async Task <OId <BankAccount, Guid> > Handle(CreateBankAccount request, CancellationToken cancellationToken) { var bankAccountId = OId.Of <BankAccount, Guid>(UniqueId.New()); var bankAccount = BankAccount.New(bankAccountId, request.AccountHolderId, request.Iban, request.AccountCurrency, request.EmployeeId, request.TimeStamp); await bankAccountRepository.SaveAsync(bankAccount).ConfigureAwait(false); return(bankAccountId); }
public BankAccountBuilder(OId <BankAccount, Guid> id) { this.id = id; employeeId = OId.Of <Employee, Guid>(Guid.Parse("309dc64d-bde5-4ee5-9e21-33a517e2fe35")); accountHolderId = OId.Of <AccountHolder, Guid>(Guid.Parse("59ed2782-881b-49a9-8230-d0b3bb1c9072")); iban = Iban.Of("DE37200505501340426749"); accountCurrency = Currency.Euro; }
public CreateBankAccount(OId <AccountHolder, Guid> accountHolderId, OId <Employee, Guid> employeeId, Currency accountCurrency, Iban iban, TimeStamp timeStamp) : base(timeStamp) { AccountHolderId = accountHolderId; EmployeeId = employeeId; AccountCurrency = accountCurrency; Iban = iban; }
public async Task <CoreDomain.BankAccount> GetByIdAsync(OId <CoreDomain.BankAccount, Guid> id) { var eventStoreConnection = await connect().ConfigureAwait(false); var events = await eventStoreConnection.ReadStreamEventsForwardAsync(MakeStreamName(nameof(CoreDomain.BankAccount), id.Value), 0, 4000, false); var bankAccountEvents = events.Events.Select(it => Encoding.UTF8.GetString(it.Event.Data)).Select(it => JsonConvert.DeserializeObject(it, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Objects })).Cast <BankAccountEvent>(); return(CoreDomain.BankAccount.Rehydrate(id, bankAccountEvents)); }
private static Task CreateAccountAsync(IMediator mediator) { System.Console.Clear(); System.Console.Write("IBAN: "); var iban = Iban.Of(System.Console.ReadLine()); var createBankAccount = new CreateBankAccount(OId.Of <AccountHolder, Guid>(Guid.NewGuid()), OId.Of <Employee, Guid>(EmployeeId), Currency.Euro, iban, TimeStamp.Of(DateTimeOffset.Now.ToUnixTimeSeconds())); return(mediator.Send(createBankAccount)); }
private static Task Deposit(IMediator mediator, AvailableAccountsProjection availableAccountsProjection) { System.Console.Clear(); System.Console.Write("IBAN: "); var iban = Iban.Of(System.Console.ReadLine()); System.Console.Write("Amount: "); var amount = decimal.Parse(System.Console.ReadLine()); var bankAccountId = OId.Of <CoreDomain.BankAccount, Guid>(availableAccountsProjection.GetId(iban)); var depositMoney = new DepositMoney(bankAccountId, Transaction.Of(Guid.NewGuid()), new Money(amount, Currency.Euro), TimeStamp.Of(DateTimeOffset.Now.ToUnixTimeSeconds())); return(mediator.Send(depositMoney)); }
/// <summary> /// Get the hash code for this object /// </summary> /// /// <returns>Hash code</returns> public override int GetHashCode() { int prime = 31; int result = 1; result = prime * result + N; result = prime * result + BufferLenBits; result = prime * result + _bufferLenTrits; result = prime * result + CBits; result = prime * result + Db; result = prime * result + DF; result = prime * result + DF1; result = prime * result + DF2; result = prime * result + DF3; result = prime * result + Dg; result = prime * result + Dm0; result = prime * result + MaxM1; result = prime * result + DR; result = prime * result + DR1; result = prime * result + DR2; result = prime * result + DR3; result = prime * result + (FastFp ? 1231 : 1237); result = prime * result + Digest.GetHashCode(); result = prime * result + RandomEngine.GetHashCode(); result = prime * result + (HashSeed ? 1231 : 1237); result = prime * result + Length; result = prime * result + MessageMax; result = prime * result + MinMGFHashCalls; result = prime * result + MinIGFHashCalls; result = prime * result + OId.GetHashCode(); result = prime * result + PkLen; result = prime * result + PolyType.GetHashCode(); result = prime * result + Q; result = prime * result + (Sparse ? 1231 : 1237); return(result); }
public void CreateNewBankAccount_Always_SavesNewBankAccount() { var bankAccountRepository = Substitute.For <IBankAccountRepository>(); var systemUnderTest = new CreateBankAccountHandler(bankAccountRepository); var employeeId = OId.Of <Employee, Guid>(Guid.Parse("309dc64d-bde5-4ee5-9e21-33a517e2fe35")); var accountHolderId = OId.Of <AccountHolder, Guid>(Guid.Parse("59ed2782-881b-49a9-8230-d0b3bb1c9072")); var iban = Iban.Of("DE37200505501340426749"); const int unixTimestamp = 1; var command = new CreateBankAccount(accountHolderId, employeeId, Currency.Euro, iban, TimeStamp.Of(unixTimestamp)); var expectedAccountId = Guid.Parse("5fd9c8fe-2a2c-4d76-9c57-2460dd516dbf"); UniqueId.OverrideNewGuid(expectedAccountId); systemUnderTest.Handle(command, CancellationToken.None).GetAwaiter().GetResult(); var expectedEvents = new BankAccountEvent[] { new BankAccountCreated(expectedAccountId, accountHolderId.Value, iban.Value, Currency.Euro.Value, employeeId.Value, unixTimestamp) }; bankAccountRepository.Received() .SaveAsync(Arg.Is <BankAccount>(it => it.IsCorrectBankAccount(aggregate => aggregate.Id.Value.Equals(expectedAccountId) && aggregate.Version == 1 && aggregate.GetUncommittedEvents().SequenceEqual(expectedEvents)))); UniqueId.ResetOverride(); }
public static BankAccount RehydrateWithCreatedEvent(OId <BankAccount, Guid> accountId) => RehydrateWithCreatedEvent(accountId, Currency.Euro);
protected AggregateRoot(OId <TAggregate, Guid> id) { this.id = id; AggregateId = id; }
public VermerkeGutschrift(OId <BankAccount, Guid> bankAccountId, Money amount, TimeStamp timeStamp) : base(timeStamp) { BankAccountId = bankAccountId; Amount = amount; }
public static bool IsCorrectBankAccount(this BankAccount bankAccount, OId <BankAccount, Guid> accountId, int expectedVersion, Func <IAggregateRoot <BankAccount, BankAccountEvent>, bool> assertion) { return(bankAccount.IsCorrectBankAccount(it => it.Id.Equals(accountId) && it.Version.Equals(expectedVersion) && assertion(bankAccount))); }
public static bool IsCorrectBankAccount(this BankAccount bankAccount, OId <BankAccount, Guid> accountId, int expectedVersion, IEnumerable <BankAccountEvent> expectedEvents) { return(bankAccount.IsCorrectBankAccount(accountId, expectedVersion, it => it.GetUncommittedEvents().SequenceEqual(expectedEvents))); }
public static BankAccount RehydrateWithCreatedEvent(OId <BankAccount, Guid> accountId, Currency currency) => new BankAccountBuilder(accountId).WithCurrency(currency).Build();
public CloseBankAccount(OId <BankAccount, Guid> id) { Id = id; }
public Employee(OId <Employee, Guid> id) { Id = id; }
public AccountHolder(OId <AccountHolder, Guid> id) { Id = id; }