private void HandleDeleteExperiment(DeleteExperiment deleteExperiment)
        {
            Result deletionResult = _repository.DeleteExperiment(deleteExperiment);

            if (deletionResult.IsFailure)
            {
                ExperimentDeletionFailed failedExperimentDeletion =
                    new ExperimentDeletionFailed(
                        deletionResult.Error,
                        deleteExperiment.LoggedInUserId,
                        deleteExperiment.SagaId
                        );
                _kafkaProducer.Produce(failedExperimentDeletion, EXPERIMENT_TOPIC);
                return;
            }

            ExperimentDeleted deletedExperiment =
                new ExperimentDeleted(
                    deleteExperiment.Id,
                    deleteExperiment.LoggedInUserId,
                    deleteExperiment.SagaId
                    );

            _kafkaProducer.Produce(deletedExperiment, EXPERIMENT_TOPIC);
        }
示例#2
0
        public ActionResult DeleteExperimentForPlant([FromRoute] Guid plantId, [FromRoute] Guid experimentId)
        {
            if (!_experimentRepository.PlantExists(plantId))
            {
                return(NotFound());
            }

            var experimentForPlantFromRepo = _experimentRepository.GetExperiment(plantId, experimentId);

            if (experimentForPlantFromRepo == null)
            {
                return(NotFound());
            }

            _experimentRepository.DeleteExperiment(experimentForPlantFromRepo);
            _experimentRepository.Save();

            return(NoContent());
        }