public static void LoadTypes() { VoucherIssuedEvent v = new VoucherIssuedEvent(Guid.NewGuid(), Guid.NewGuid(), DateTime.Now, "", ""); TransactionHasStartedEvent t = new TransactionHasStartedEvent(Guid.Parse("2AA2D43B-5E24-4327-8029-1135B20F35CE"), Guid.NewGuid(), Guid.NewGuid(), DateTime.Now, "", "", "", "", null); ReconciliationHasStartedEvent r = new ReconciliationHasStartedEvent(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), DateTime.Now); EstateCreatedEvent e = new EstateCreatedEvent(Guid.NewGuid(), ""); MerchantCreatedEvent m = new MerchantCreatedEvent(Guid.NewGuid(), Guid.NewGuid(), "", DateTime.Now); ContractCreatedEvent c = new ContractCreatedEvent(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), ""); MerchantBalanceChangedEvent mb = new MerchantBalanceChangedEvent(Guid.NewGuid(), Guid.NewGuid(), DateTime.Now, Guid.NewGuid(), Guid.NewGuid(), 0, 0, 0, ""); ImportLogCreatedEvent i = new ImportLogCreatedEvent(Guid.NewGuid(), Guid.NewGuid(), DateTime.MinValue); FileCreatedEvent f = new FileCreatedEvent(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), String.Empty, DateTime.MinValue); SettlementCreatedForDateEvent s = new SettlementCreatedForDateEvent(Guid.NewGuid(), Guid.NewGuid(), DateTime.Now); StatementCreatedEvent ms = new StatementCreatedEvent(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), DateTime.Now); TypeProvider.LoadDomainEventsTypeDynamically(); }
/// <summary> /// Plays the event. /// </summary> /// <param name="domainEvent">The domain event.</param> private void PlayEvent(ContractCreatedEvent domainEvent) { this.IsCreated = true; this.OperatorId = domainEvent.OperatorId; this.EstateId = domainEvent.EstateId; this.Description = domainEvent.Description; }
public void Handle(ContractCreatedEvent evt) { _logger.LogInformation(GetLogMessage("Contract Created Event Triggered")); Parallel.Invoke(new List <Action> { () => ContractCreatedSendContractorEmail(evt.ContractId), () => ContractCreatedSendProjectManagerEmail(evt.ContractId), () => ContractCreatedSendAccountManagerEmail(evt.ContractId), () => ContractCreatedSendAgencyOwnerEmail(evt.ContractId) }.ToArray()); }
public void ContractDomainEventHandler_ContractCreatedEvent_EventIsHandled() { ContractCreatedEvent contractCreatedEvent = TestData.ContractCreatedEvent; Mock <IEstateReportingRepository> estateReportingRepository = new Mock <IEstateReportingRepository>(); ContractDomainEventHandler eventHandler = new ContractDomainEventHandler(estateReportingRepository.Object); Logger.Initialise(NullLogger.Instance); Should.NotThrow(async() => { await eventHandler.Handle(contractCreatedEvent, CancellationToken.None); }); }
/// <summary> /// Creates the specified estate identifier. /// </summary> /// <param name="estateId">The estate identifier.</param> /// <param name="operatorId">The operator identifier.</param> /// <param name="description">The description.</param> public void Create(Guid estateId, Guid operatorId, String description) { Guard.ThrowIfInvalidGuid(estateId, typeof(ArgumentNullException), "Estate Id must not be an empty Guid"); Guard.ThrowIfInvalidGuid(operatorId, typeof(ArgumentNullException), "Operator Id must not be an empty Guid"); Guard.ThrowIfNullOrEmpty(description, typeof(ArgumentNullException), "Contract description must not be null or empty"); ContractCreatedEvent contractCreatedEvent = new ContractCreatedEvent(this.AggregateId, estateId, operatorId, description); this.ApplyAndAppend(contractCreatedEvent); }
public void ContractCreatedEvent_CanBeCreated_IsCreated() { ContractCreatedEvent contractCreatedEvent = new ContractCreatedEvent(TestData.ContractId, TestData.EstateId, TestData.OperatorId, TestData.ContractDescription); contractCreatedEvent.ShouldNotBeNull(); contractCreatedEvent.AggregateId.ShouldBe(TestData.ContractId); contractCreatedEvent.EventId.ShouldNotBe(Guid.Empty); contractCreatedEvent.ContractId.ShouldBe(TestData.ContractId); contractCreatedEvent.Description.ShouldBe(TestData.ContractDescription); contractCreatedEvent.OperatorId.ShouldBe(TestData.OperatorId); contractCreatedEvent.EstateId.ShouldBe(TestData.EstateId); }
partial void HandleImplementation(ContractCreatedEvent message) { // TODO: SendTermsOfUsageHandler: Add code to handle the ContractCreatedEvent message. Console.WriteLine("PremiumMembership received " + message.GetType().Name); }
/// <summary> /// Handles the specific domain event. /// </summary> /// <param name="domainEvent">The domain event.</param> /// <param name="cancellationToken">The cancellation token.</param> private async Task HandleSpecificDomainEvent(ContractCreatedEvent domainEvent, CancellationToken cancellationToken) { await this.EstateReportingRepository.AddContract(domainEvent, cancellationToken); }
partial void HandleImplementation(ContractCreatedEvent message) { // TODO: ContractCreatedEventHandler: Add code to handle the ContractCreatedEvent message. Console.WriteLine("Accounting received " + message.GetType().Name); }
// This method gets called by the runtime. Use this method to add services to the container. /// <summary> /// Configures the services. /// </summary> /// <param name="services">The services.</param> public void ConfigureServices(IServiceCollection services) { ConfigurationReader.Initialise(Startup.Configuration); Startup.ConfigureEventStoreSettings(); this.ConfigureMiddlewareServices(services); services.AddTransient <IMediator, Mediator>(); services.AddSingleton <IEstateManagementManager, EstateManagementManager>(); Boolean useConnectionStringConfig = Boolean.Parse(ConfigurationReader.GetValue("AppSettings", "UseConnectionStringConfig")); if (useConnectionStringConfig) { String connectionStringConfigurationConnString = ConfigurationReader.GetConnectionString("ConnectionStringConfiguration"); services.AddSingleton <IConnectionStringConfigurationRepository, ConnectionStringConfigurationRepository>(); services.AddTransient <ConnectionStringConfigurationContext>(c => { return(new ConnectionStringConfigurationContext(connectionStringConfigurationConnString)); }); // TODO: Read this from a the database and set } else { services.AddEventStoreClient(Startup.ConfigureEventStoreSettings); services.AddEventStoreProjectionManagerClient(Startup.ConfigureEventStoreSettings); services.AddEventStorePersistentSubscriptionsClient(Startup.ConfigureEventStoreSettings); services.AddSingleton <IConnectionStringConfigurationRepository, ConfigurationReaderConnectionStringRepository>(); } services.AddTransient <IEventStoreContext, EventStoreContext>(); services.AddSingleton <IEstateManagementRepository, EstateManagementRepository>(); services.AddSingleton <IDbContextFactory <EstateReportingContext>, DbContextFactory <EstateReportingContext> >(); Dictionary <String, String[]> handlerEventTypesToSilentlyHandle = new Dictionary <String, String[]>(); if (Startup.Configuration != null) { IConfigurationSection section = Startup.Configuration.GetSection("AppSettings:HandlerEventTypesToSilentlyHandle"); if (section != null) { Startup.Configuration.GetSection("AppSettings:HandlerEventTypesToSilentlyHandle").Bind(handlerEventTypesToSilentlyHandle); } } services.AddSingleton <Func <String, EstateReportingContext> >(cont => (connectionString) => { return(new EstateReportingContext(connectionString)); }); DomainEventTypesToSilentlyHandle eventTypesToSilentlyHandle = new DomainEventTypesToSilentlyHandle(handlerEventTypesToSilentlyHandle); services.AddTransient <IEventStoreContext, EventStoreContext>(); services.AddSingleton <IAggregateRepository <EstateAggregate.EstateAggregate, DomainEventRecord.DomainEvent>, AggregateRepository <EstateAggregate.EstateAggregate, DomainEventRecord.DomainEvent> >(); services.AddSingleton <IAggregateRepository <MerchantAggregate.MerchantAggregate, DomainEventRecord.DomainEvent>, AggregateRepository <MerchantAggregate.MerchantAggregate, DomainEventRecord.DomainEvent> >(); services.AddSingleton <IAggregateRepository <ContractAggregate.ContractAggregate, DomainEventRecord.DomainEvent>, AggregateRepository <ContractAggregate.ContractAggregate, DomainEventRecord.DomainEvent> >(); services.AddSingleton <IEstateDomainService, EstateDomainService>(); services.AddSingleton <IMerchantDomainService, MerchantDomainService>(); services.AddSingleton <IContractDomainService, ContractDomainService>(); services.AddSingleton <IModelFactory, ModelFactory>(); services.AddSingleton <Factories.IModelFactory, Factories.ModelFactory>(); services.AddSingleton <ISecurityServiceClient, SecurityServiceClient>(); ContractCreatedEvent c = new ContractCreatedEvent(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), ""); MerchantCreatedEvent m = new MerchantCreatedEvent(Guid.NewGuid(), Guid.NewGuid(), "", DateTime.Now); EstateCreatedEvent e = new EstateCreatedEvent(Guid.NewGuid(), ""); TypeProvider.LoadDomainEventsTypeDynamically(); // request & notification handlers services.AddTransient <ServiceFactory>(context => { return(t => context.GetService(t)); }); services.AddSingleton <IRequestHandler <CreateEstateRequest, String>, EstateRequestHandler>(); services.AddSingleton <IRequestHandler <CreateEstateUserRequest, Guid>, EstateRequestHandler>(); services.AddSingleton <IRequestHandler <AddOperatorToEstateRequest, String>, EstateRequestHandler>(); services.AddSingleton <IRequestHandler <CreateMerchantRequest, String>, MerchantRequestHandler>(); services.AddSingleton <IRequestHandler <AssignOperatorToMerchantRequest, String>, MerchantRequestHandler>(); services.AddSingleton <IRequestHandler <CreateMerchantUserRequest, Guid>, MerchantRequestHandler>(); services.AddSingleton <IRequestHandler <AddMerchantDeviceRequest, String>, MerchantRequestHandler>(); services.AddSingleton <IRequestHandler <MakeMerchantDepositRequest, Guid>, MerchantRequestHandler>(); services.AddSingleton <IRequestHandler <CreateContractRequest, String>, ContractRequestHandler>(); services.AddSingleton <IRequestHandler <AddProductToContractRequest, String>, ContractRequestHandler>(); services.AddSingleton <IRequestHandler <AddTransactionFeeForProductToContractRequest, String>, ContractRequestHandler>(); services.AddSingleton <Func <String, String> >(container => (serviceName) => { return(ConfigurationReader.GetBaseServerUri(serviceName).OriginalString); }); HttpClientHandler httpClientHandler = new HttpClientHandler { ServerCertificateCustomValidationCallback = (message, certificate2, arg3, arg4) => { return(true); } }; HttpClient httpClient = new HttpClient(httpClientHandler); services.AddSingleton <HttpClient>(httpClient); }