public UserProfileCommandService( IAggregateStore store, CheckTextForProfanity checkText ) : base(store) { CreateWhen <V1.RegisterUser>( cmd => new UserId(cmd.UserId), (cmd, id) => UserProfile.Create( new UserId(id), FullName.FromString(cmd.FullName), DisplayName.FromString(cmd.DisplayName, checkText) ) ); UpdateWhen <V1.UpdateUserFullName>( cmd => new UserId(cmd.UserId), (user, cmd) => user.UpdateFullName(FullName.FromString(cmd.FullName)) ); UpdateWhen <V1.UpdateUserDisplayName>( cmd => new UserId(cmd.UserId), (user, cmd) => user.UpdateDisplayName( DisplayName.FromString(cmd.DisplayName, checkText) ) ); UpdateWhen <V1.UpdateUserProfilePhoto>( cmd => new UserId(cmd.UserId), (user, cmd) => user.UpdateProfilePhoto(new Uri(cmd.PhotoUrl)) ); }
public UserProfileApplicationService( IAggregateStore store, CheckTextForProfanity checkText) { _store = store; _checkText = checkText; }
public ClassifiedAdsApplicationService( IAggregateStore store, Func <DateTimeOffset> getUtcNow, CheckTextForProfanity checkTextForProfanity) { _store = store; _getUtcNow = getUtcNow; _checkTextForProfanity = checkTextForProfanity; }
public UserProfileApplicationService( IUserProfileRepository repository, IUnitOfWork unitOfWork, CheckTextForProfanity checkText) { _repository = repository; _unitOfWork = unitOfWork; _checkText = checkText; }
public RegisterUserCommandHandler( IUserRepository repo, IAggregateStore stone, CheckTextForProfanity checkText) { _repo = repo; _store = stone; _checkText = checkText; }
public UpdateUserDisplayNameCommandHandler( IUserRepository repo, IAggregateStore store, CheckTextForProfanity checkText ) { _repo = repo; _store = store; _checkText = checkText; }
public static IMvcCoreBuilder AddUsersModule( this IMvcCoreBuilder builder, string databaseName, CheckTextForProfanity profanityCheck ) { EventMappings.MapEventTypes(); builder.Services.AddSingleton( c => new UserProfileCommandService( new EsAggregateStore( c.GetRequiredService <IEventStoreConnection>() ), profanityCheck ) ) .AddSingleton <GetUsersModuleSession>( c => { var store = c.GetRequiredService <IDocumentStore>(); store.CheckAndCreateDatabase(databaseName); IAsyncDocumentSession GetSession() => store.OpenAsyncSession(databaseName); return(GetSession); } ) .AddSingleton( c => { var getSession = c.GetRequiredService <GetUsersModuleSession>(); return(new SubscriptionManager( c.GetRequiredService <IEventStoreConnection>(), new RavenDbCheckpointStore( () => getSession(), SubscriptionName ), SubscriptionName, new RavenDbProjection <UserDetails>( () => getSession(), UserDetailsProjection.GetHandler ) )); } ) .AddSingleton <AuthService>(); builder.AddApplicationPart(typeof(UsersModule).Assembly); return(builder); }
public static DisplayName FromString(string displayName, CheckTextForProfanity hasProfanity) { if (string.IsNullOrWhiteSpace(displayName)) { throw new ArgumentNullException(nameof(displayName)); } if (hasProfanity(displayName)) { throw new ProfanityFoundException(displayName); } return(new DisplayName(displayName)); }
public async Task UpdateText(AdText text, UserId updatedBy, Func <DateTimeOffset> getUtcNow, CheckTextForProfanity checkTextForProfanity) { if (Version == -1) { throw new Exceptions.ClassifiedAdNotFoundException(); } var containsProfanity = await checkTextForProfanity(text); if (containsProfanity) { throw new Exceptions.ProfanityFound(); } Apply(new Events.V1.ClassifiedAdTextUpdated { Id = Id, Owner = _owner, AdText = text, TextUpdatedBy = updatedBy, TextUpdatedAt = getUtcNow() }); }