protected AggregateGuid(string id)
        {
            var tokens = id.Split(_delimiter);

            TenantId = TenantId.Create(tokens[0]);
            Id       = Guid.Parse(tokens[1]);
        }
Beispiel #2
0
        public async Task Handle(UserCreatedEvent notification, CancellationToken cancellationToken)
        {
            var model = new UserModel
            {
                Id                 = notification.EntityId,
                Email              = notification.Email,
                Firstname          = notification.Firstname,
                Lastname           = notification.Lastname,
                Password           = notification.Password,
                LastCommittedEvent = notification.EventId
            };

            await _documentRepository.Insert(model, TenantId.Create(notification.TenantId));

            _logger.LogInformation($"User {notification.Email} has been projected");
        }
Beispiel #3
0
        public async Task Handle(UserPasswordUpdatedEvent notification, CancellationToken cancellationToken)
        {
            var model = await _documentRepository
                        .SingleOrDefault(m => m.Id == notification.EntityId);

            if (model == null)
            {
                return;
            }

            model.Password = notification.HashedPassword;
            await _documentRepository.Update(model, m => m.Id == notification.EntityId,
                                             TenantId.Create(notification.TenantId));

            _logger.LogInformation($"User {model.Email} password has been projected");
        }
        protected static TId Create <TId>(string tenantId = null) where TId : class, IAggregateId <Guid>
        {
            var tenant      = string.IsNullOrWhiteSpace(tenantId) ? TenantId.Default : TenantId.Create(tenantId);
            var constructor = typeof(TId).GetConstructor(
                BindingFlags.NonPublic | BindingFlags.Instance,
                null,
                new[] { typeof(TenantId) },
                null
                );
            var aggregateId = (TId)constructor?.Invoke(new object[] { tenant });

            return(aggregateId);
        }
 public UserTests()
 {
     Register(() => TenantId.Create("dev"));
     Register(() => UserId.Create("dev"));
     Register(() => new User(Fixture.Create <UserId>()));
 }