Example #1
0
 public async Task HandleAsync(SignedIn @event)
 {
     await _handler
     .Run(async() =>
     {
         var user = await _userServiceClient.GetAsync <User>(@event.UserId);
         await _accountStateService.SetAsync(user.Value.UserId, user.Value.State);
         await _cache.AddAsync(user.Value);
     })
     .OnError((ex, logger) =>
     {
         logger.Error(ex, $"Error occured while handling {@event.GetType().Name} event");
     })
     .ExecuteAsync();
 }
        public async Task HandleAsync(AccountDeleted @event)
        {
            await _handler
            .Run(async() =>
            {
                if (@event.Soft)
                {
                    var user         = await _userRepository.GetByIdAsync(@event.UserId);
                    user.Value.State = "deleted";
                    await _userRepository.EditAsync(user.Value);
                    await _stateService.SetAsync(@event.UserId, user.Value.State);

                    return;
                }
                await _cache.DeleteAsync(@event.UserId);
                await _stateService.SetAsync(@event.UserId, "deleted");
                await _userRepository.DeleteAsync(@event.UserId);
            })
            .OnError((ex, logger) =>
            {
                logger.Error(ex, $"Error occured while handling {@event.GetType().Name} event");
            })
            .ExecuteAsync();
        }
Example #3
0
 public async Task HandleAsync(AccountActivated @event)
 {
     await _handler
     .Run(async() =>
     {
         var user         = await _repository.GetByIdAsync(@event.UserId);
         user.Value.State = "active";
         await _repository.EditAsync(user.Value);
         await _stateService.SetAsync(user.Value.UserId, user.Value.State);
         await _cache.AddAsync(user.Value);
     })
     .OnError((ex, logger) =>
     {
         logger.Error(ex, $"Error occured while handling {@event.GetType().Name} event");
     })
     .ExecuteAsync();
 }
 public async Task HandleAsync(SignedUp @event)
 {
     await _handler
     .Run(async() =>
     {
         var user = await _userServiceClient.GetAsync <User>(@event.UserId);
         user.Value.FavoriteRemarks = new HashSet <Guid>();
         user.Value.Groups          = new HashSet <UserGroup>();
         user.Value.Organizations   = new HashSet <UserOrganization>();
         await _repository.AddAsync(user.Value);
         await _accountStateService.SetAsync(user.Value.UserId, user.Value.State);
         await _cache.AddAsync(user.Value);
     })
     .OnError((ex, logger) =>
     {
         logger.Error(ex, $"Error occured while handling {@event.GetType().Name} event");
     })
     .ExecuteAsync();
 }