private void HandleUpdateExperiment(UpdateExperiment updateExperiment)
        {
            Result <Experiment> updatedExperimentResult = _repository.UpdateExperiment(updateExperiment);

            if (updatedExperimentResult.IsFailure)
            {
                ExperimentUpdateFailed failedExperimentUpdate =
                    new ExperimentUpdateFailed(
                        updatedExperimentResult.Error,
                        updateExperiment.LoggedInUserId,
                        updateExperiment.SagaId
                        );
                _kafkaProducer.Produce(failedExperimentUpdate, EXPERIMENT_TOPIC);
                return;
            }

            ExperimentUpdated updatedExperiment = new ExperimentUpdated(
                updatedExperimentResult.Value.Id,
                updatedExperimentResult.Value.Creator,
                updatedExperimentResult.Value.Name,
                updatedExperimentResult.Value.CreationDate,
                updateExperiment.LoggedInUserId,
                updateExperiment.SagaId
                );

            _kafkaProducer.Produce(updatedExperiment, EXPERIMENT_TOPIC);
        }
        public Result <Experiment> UpdateExperiment(UpdateExperiment updateExperiment)
        {
            Experiment experimentToUpdate = experimentsMemoryDatabase.Find(e => e.Id == updateExperiment.Id);

            if (experimentToUpdate == null)
            {
                return(Result.Fail <Experiment>("The experiment you're trying to update does not exist"));
            }

            experimentToUpdate.Creator = updateExperiment.Creator;
            experimentToUpdate.Name    = updateExperiment.Name;

            return(Result.Ok <Experiment>(experimentToUpdate));
        }
        public IActionResult UpdateExperiment(long id, [FromBody] ExperimentDTO experimentDTO)
        {
            long loggedInUserId = GetLoggedInUserIdMockUp();

            if (loggedInUserId == -1)
            {
                return(Unauthorized());
            }

            UpdateExperiment updateExperiment =
                new UpdateExperiment(id, experimentDTO.Creator, experimentDTO.Name, loggedInUserId);

            _kafkaProducer.Produce(updateExperiment, EXPERIMENT_TOPIC);

            return(Ok("Currently processing your request..."));
        }