Exemplo n.º 1
0
 public async Task HandleAsync(UserNotificationSettingsUpdated @event)
 => await _handler
 .Run(async() =>
 {
     var settings = await _serviceClient.GetUserNotificationSettingsAsync(
         new GetUserNotificationSettings
     {
         UserId = @event.UserId
     });
     var existingSettings = await _repository.GetAsync(@event.UserId);
     if (existingSettings.HasValue)
     {
         await _repository.EditAsync(settings.Value);
     }
     else
     {
         await _repository.AddAsync(settings.Value);
     }
     await _cache.AddAsync(settings.Value);
 })
 .OnError((ex, logger) =>
 {
     logger.Error(ex, $"Error occured while handling {@event.GetType().Name} event");
 })
 .ExecuteAsync();
Exemplo n.º 2
0
 public async Task <Maybe <UserNotificationSettings> > GetUserNotificationSettingsAsync(
     GetUserNotificationSettings query)
 => await _providerClient.GetAsync(
     async() => await _repository.GetAsync(query.UserId),
     async() => await _serviceClient.GetUserNotificationSettingsAsync(query));