private void HandleCreateExperiment(CreateExperiment createExperiment)
        {
            Result <Experiment> experimentCreationResult = _repository.CreateExperiment(createExperiment);

            if (experimentCreationResult.IsFailure)
            {
                ExperimentCreationFailed failedExperiment =
                    new ExperimentCreationFailed(
                        experimentCreationResult.Error,
                        createExperiment.LoggedInUserId,
                        createExperiment.SagaId
                        );
                _kafkaProducer.Produce(failedExperiment, EXPERIMENT_TOPIC);
                return;
            }

            ExperimentCreated createdExperiment = new ExperimentCreated(
                experimentCreationResult.Value.Id,
                experimentCreationResult.Value.Creator,
                experimentCreationResult.Value.Name,
                experimentCreationResult.Value.CreationDate,
                createExperiment.LoggedInUserId,
                createExperiment.SagaId
                );

            _kafkaProducer.Produce(createdExperiment, EXPERIMENT_TOPIC);
        }
Exemplo n.º 2
0
 private async void HandleExperimentCreationFailed(ExperimentCreationFailed cf)
 {
     var failedExperiment = new { failureReason = cf.FailureReason };
     await _hubContext.Clients.Groups(cf.LoggedInUserId.ToString()).SendAsync("ReceiveExperimentCreatedMessage", failedExperiment);
 }