/// <summary>
        /// Handles the specified message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <returns></returns>
        public async Task Handle(UpdateNameCommand message)
        {
            TrialSet trialSet = await this._trialSetRepository.Get(message.TrialSetId);

            trialSet.ChangeName(message.Name);
            await this._trialSetRepository.Update(trialSet);

            this._eventBus.Publish(new TrialSetNameChangedEvent(trialSet.Id, trialSet.Name));
        }
Esempio n. 2
0
        /// <summary>
        /// Handles the specified message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <returns></returns>
        public async Task Handle(RemoveScenarioCommand message)
        {
            TrialSet trialSet = await this._trialSetRepository.Get(message.TrialSetId);

            trialSet.RemoveScenario(message.ScenarioId);
            await this._trialSetRepository.Update(trialSet);

            this._eventBus.Publish(new ScenarioRemovedFromTrialEvent(message.TrialSetId, message.ScenarioId));
        }
        public async Task <IActionResult> Post([FromBody] CreateTrialSetCommand command)
        {
            try
            {
                TrialSet trialSet = await this._mediator.Send(command);

                return(Ok(trialSet));
            }
            catch (Exception ex)
            {
                this._logger.LogError(0, ex, ex.Message);
                return(BadRequest());
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Handles the specified message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <returns></returns>
        public async Task Handle(AddScenarioCommand message)
        {
            TrialSet trialSet = await this._trialSetRepository.Get(message.TrialSetId);

            if (trialSet == null)
            {
                throw new TrialSetManagementDomainException("There is no trial set with the given identifier.");
            }

            trialSet.AddScenario(message.ScenarioId);

            await this._trialSetRepository.Update(trialSet);

            this._eventBus.Publish(new ScenarioAddedToTrialSetEvent(message.TrialSetId, message.ScenarioId));
        }