Ejemplo n.º 1
0
        public async Task HandleAsync(NewUserSignedIn @event)
        {
            var user = await _userRepository.GetAsync(@event.UserId);

            if (user.HasValue)
            {
                return;
            }

            await _userRepository.AddAsync(new User(@event.Email, @event.UserId, @event.Role, @event.State));

            await _userPaymentPlanService.CreateDefaultAsync(@event.UserId);

            var plan = await _userPaymentPlanService.GetCurrentPlanAsync(@event.UserId);

            await _bus.PublishAsync(new UserPaymentPlanCreated(Guid.NewGuid(), @event.UserId, plan.Value.Id,
                                                               plan.Value.Name, plan.Value.MonthlyPrice));
        }
Ejemplo n.º 2
0
        public async Task HandleAsync(UserSignedIn @event)
        {
            var user = await _userRepository.GetAsync(@event.UserId);

            if (user.HasValue)
            {
                return;
            }

            await _userRepository.AddAsync(new User(@event.Email, @event.UserId, @event.Role, @event.State));

            await _userPaymentPlanService.CreateDefaultAsync(@event.UserId);

            var plan = await _userPaymentPlanService.GetCurrentPlanAsync(@event.UserId);

            var addWardenChecksFeature = plan.Value.Features.First(x => x.Type == FeatureType.AddWardenCheck);
            await _wardenChecksCounter.InitializeAsync(@event.UserId, addWardenChecksFeature.Limit);

            await _bus.PublishAsync(new UserPaymentPlanCreated(Guid.NewGuid(), @event.UserId, plan.Value.Id,
                                                               plan.Value.Name, plan.Value.MonthlyPrice));
        }