예제 #1
0
        public async Task HandleAsync(CreatePoint command)
        {
            _logger.LogInformation($"Creating Point: {command.Name}");

            try
            {
                await _pointService.AddPointAsync(command.Id, command.Name,
                                                  command.UserId, command.CreatedAt);

                await _busClient.PublishAsync(new PointCreated(command.Id,
                                                               command.Name,
                                                               command.UserId, command.CreatedAt));

                return;
            }
            catch (DeliveryServiceException ex)
            {
                await _busClient.PublishAsync(new CreatePointRejected(command.Id, ex.Message, ex.Code));

                _logger.LogError(ex.Message);
            }
            catch (Exception ex)
            {
                await _busClient.PublishAsync(new CreatePointRejected(command.Id, ex.Message, "error"));

                _logger.LogError(ex.Message);
            }
        }