コード例 #1
0
        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);
        }
コード例 #2
0
 private ChangeUserEmailCommand BuildChangeUserEmailCommand(string userId, string newUserEmail, int version)
 {
     return(new ChangeUserEmailCommand()
     {
         UserId = UserId.FromString(userId), NewUserEmail = newUserEmail, Version = version
     });
 }
コード例 #3
0
 private CreateUserCommand BuildCreateUserCommand(string userId, string userName, string userEmail, int version)
 {
     return(new CreateUserCommand()
     {
         UserId = UserId.FromString(userId), UserName = userName, UserEmail = userEmail, Version = version
     });
 }
コード例 #4
0
 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);
 }
コード例 #5
0
        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);
        }
コード例 #6
0
        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();
        }
コード例 #7
0
        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
            });
        }
コード例 #8
0
        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();
        }
コード例 #9
0
        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));
        }
コード例 #10
0
        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;
            }
        }
コード例 #11
0
        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));
        }
コード例 #12
0
 public static Customer FromDalModel(CustomerDal customerDal)
 {
     return(new Customer(UserId.FromString(customerDal.Id), customerDal.FirstName, customerDal.SurName));
 }