public async Task HandleAsync(OperationUpdated @event)
        {
            await _handler
            .Run(async() =>
            {
                var operation = await _cache.GetAsync(@event.RequestId);
                if (operation.HasNoValue)
                {
                    return;
                }

                operation.Value.State     = @event.State;
                operation.Value.Code      = @event.Code;
                operation.Value.Message   = @event.Message;
                operation.Value.UpdatedAt = @event.UpdatedAt;
                await _cache.AddAsync(operation.Value);
            })
            .OnError((ex, logger) =>
            {
                logger.Error(ex, $"Error occured while handling {@event.GetType().Name} event");
            })
            .ExecuteAsync();
        }
Ejemplo n.º 2
0
 public async Task HandleAsync(OperationCreated @event)
 {
     await _handler
     .Run(async() =>
     {
         var operation = new Operation
         {
             Id        = Guid.NewGuid(),
             RequestId = @event.RequestId,
             Name      = @event.Name,
             UserId    = @event.UserId,
             Origin    = @event.Origin,
             Resource  = @event.Resource,
             State     = @event.State,
             CreatedAt = @event.CreatedAt
         };
         await _cache.AddAsync(operation);
     })
     .OnError((ex, logger) =>
     {
         logger.Error(ex, $"Error occured while handling {@event.GetType().Name} event");
     })
     .ExecuteAsync();
 }