Exemplo n.º 1
0
        public async override Task Execute(SagaContext context)
        {
            var proRole = await repo.FindByName("Pro");

            if (proRole == null)
            {
                await repo.Add(new Role("Pro"));
            }

            var expiredRole = await repo.FindByName("Free");

            if (expiredRole == null)
            {
                await repo.Add(new Role("Free"));
            }
        }
Exemplo n.º 2
0
        public async override Task Execute(SagaContext context)
        {
            var dabaseConfigRes = await databaseConfigValidator.ValidateAsync(databaseConfig);

            if (!dabaseConfigRes.IsValid)
            {
                throw new ValidationException(dabaseConfigRes);
            }

            var auth0ConfigRes = await auth0ConfigValidator.ValidateAsync(auth0Config);

            if (!auth0ConfigRes.IsValid)
            {
                throw new ValidationException(auth0ConfigRes);
            }

            var emailConfigRes = await emailConfigValidator.ValidateAsync(emailConfig);

            if (!emailConfigRes.IsValid)
            {
                throw new ValidationException(emailConfigRes);
            }

            var adminConfigRes = await adminConfigValidator.ValidateAsync(adminConfig);

            if (!adminConfigRes.IsValid)
            {
                throw new ValidationException(adminConfigRes);
            }

            var billingConfigRes = await billingConfigValidator.ValidateAsync(billingConfig);

            if (!billingConfigRes.IsValid)
            {
                throw new ValidationException(billingConfigRes);
            }
        }
Exemplo n.º 3
0
        public async override Task Execute(SagaContext <string> context)
        {
            var cachedUser = await userRepo.FindByAuth0Id(context.Input);

            if (cachedUser != null)
            {
                context.Data.User = cachedUser;
                return;
            }

            var newUser = await userGateway.GetUserByAuth0Id(context.Input);

            // TODO: Switch to webhooks to avoid this.
            try {
                await userRepo.Add(newUser);
            } catch {
                Console.WriteLine("0_CreateUser: Duplicate user attempted to be created. Just use webhooks already");
            }

            // refactor this. Events should come from entity?
            _ = eventPublisher.Dispatch(new NewUserCreatedEvent(newUser));

            context.Data.User = newUser;
        }
Exemplo n.º 4
0
#pragma warning disable 1998
        public async override Task Execute(SagaContext context)
        {
            migrationRunner.MigrateUp();
        }