internal void CreateUserCreatedEventAndSaveOnEventStore(string userCreateUserId, string userCreatedUserName, string userCreatedUserEmail, int userCreatedVersion, string createUserUserId, string createUserUserName, string createUserUserEmail, int createUserVersion) { var createUserCommand = BuildCreateUserCommand(createUserUserId, createUserUserName, createUserUserEmail, createUserVersion); var userCreatedEvent = BuildUserCreatedEvent(UserId.FromString(userCreateUserId), userCreatedUserName, userCreatedUserEmail, userCreatedVersion); EventStore.SaveEvents(createUserCommand, EntityId.FromString(userCreateUserId), new IEvent[] { userCreatedEvent }, createUserCommand.Version); }
private ChangeUserEmailCommand BuildChangeUserEmailCommand(string userId, string newUserEmail, int version) { return(new ChangeUserEmailCommand() { UserId = UserId.FromString(userId), NewUserEmail = newUserEmail, Version = version }); }
private CreateUserCommand BuildCreateUserCommand(string userId, string userName, string userEmail, int version) { return(new CreateUserCommand() { UserId = UserId.FromString(userId), UserName = userName, UserEmail = userEmail, Version = version }); }
internal void AssertThatCommandHandlerReceivedCreateUserCommand(string userId, string userName, string userEmail, int version) { CreateUserCommandReceivedOnHandler.Should().NotBeNull(); CreateUserCommandReceivedOnHandler.UserId.Should().Be(UserId.FromString(userId)); CreateUserCommandReceivedOnHandler.UserName.Should().Be(userName); CreateUserCommandReceivedOnHandler.UserEmail.Should().Be(userEmail); CreateUserCommandReceivedOnHandler.Version.Should().Be(version); }
internal void AssertThatUserIsSavedRepository(string userId, string userName, string userEmail, int version) { var user = FindUserOnRepository(userId); user.Should().NotBeNull(); user.Id.Should().Be(UserId.FromString(userId)); user.Name.Should().Be(userName); user.Email.Should().Be(userEmail); user.Version.Should().Be(version); }
internal void AssertThatUserEmailChangedWasPublished(string userId, string userName, string newUserEmail, int version) { var userEventChangedEvent = BuildUserEmailChangedEvent(UserId.FromString(userId), userName, newUserEmail, version); userEventChangedEvent.Should().NotBeNull(); var userEmailChangedPublished = PublisedUserEmailChangedEvents.FirstOrDefault(s => s.UserId == userEventChangedEvent.UserId && s.Version == userEventChangedEvent.Version); userEmailChangedPublished.Should().NotBeNull(); AreUserEmailChangeEventsEqual(userEmailChangedPublished, userEventChangedEvent).Should().BeTrue(); }
private Snapshot <User> BuildUserSnapshotEvent(string userId, string userName, string userEmail, int version) { var user = new User(); user.Id = UserId.FromString(userId); user.Name = userName; user.Email = userEmail; user.Version = version; return(new Snapshot <User>() { Object = user, Version = version }); }
internal void AssertThatUserEmailChangedEventWasnotStoredOnEventStore(string userId, string userName, string newUserEmail, int version) { var userEventChangedEvent = BuildUserEmailChangedEvent(UserId.FromString(userId), userName, newUserEmail, version); userEventChangedEvent.Should().NotBeNull(); var userEvents = EventStore.AllEvents(EntityId.FromString(userId)); var userEmailChangedEventWasStoredOnEventStore = userEvents.Any(userEvent => { return(IsOfType <UserEmailChanged>(userEvent) && AreUserEmailChangeEventsEqual(userEventChangedEvent, userEvent as UserEmailChanged)); }); userEmailChangedEventWasStoredOnEventStore.Should().BeFalse(); }
public static Travel FromDalModel(TravelDal travelDal) { List <Customer> customers = new List <Customer>(); if (travelDal.Customers != null && travelDal.Customers.Count > 0) { foreach (var customer in travelDal.Customers) { customers.Add(new Customer(UserId.FromString(customer.Id), customer.FirstName, customer.SurName)); } } return(new Travel(TravelId.FromString(travelDal.Id), travelDal.Destination, customers)); }
internal void CreateUserEmailChangedEventAndSaveOnEventStore(string userEmailChangedUserId, string userEmailChangedUserName, string userEmailChangedNewUserEmail, int userEmailChangedEventVersion, string createUserUserId, string createUserUserEmail, int createUserVersion) { var changeUserEmailCommand = BuildChangeUserEmailCommand(createUserUserId, createUserUserEmail, createUserVersion); var userEmailChangedEvent = BuildUserEmailChangedEvent(UserId.FromString(userEmailChangedUserId), userEmailChangedUserName, userEmailChangedNewUserEmail, userEmailChangedEventVersion); try { EventStore.SaveEvents(changeUserEmailCommand, EntityId.FromString(userEmailChangedUserId), new IEvent[] { userEmailChangedEvent }, changeUserEmailCommand.Version); } catch (ConcurrencyException e) { ConcurrencyTransactionException = e; } }
public void Configure(EntityTypeBuilder <Advertisement> builder) { builder.Property(c => c.Price).HasConversion(c => c.Value.Value, d => Price.FromLong(d)); builder.Property(c => c.OwnerId).HasConversion(c => c.Value.ToString(), d => UserId.FromString(d)); builder.Property(c => c.ApprovedBy).HasConversion(c => c.Value.ToString(), d => UserId.FromString(d)); builder.Property(c => c.Description).HasConversion(c => c.Value, d => AdvertisementDescription.FromString(d)); builder.Property(c => c.Title).HasConversion(c => c.Value, d => AdvertisementTitle.FromString(d)); }
public static Customer FromDalModel(CustomerDal customerDal) { return(new Customer(UserId.FromString(customerDal.Id), customerDal.FirstName, customerDal.SurName)); }