public async Task <IActionResult> CreateCohortGroup( [FromBody] CohortGroupForUpdateDto cohortGroupForUpdate) { if (cohortGroupForUpdate == null) { ModelState.AddModelError("Message", "Unable to locate payload for new request"); } var command = new AddCohortGroupCommand(cohortGroupForUpdate.CohortName, cohortGroupForUpdate.CohortCode, cohortGroupForUpdate.StartDate, cohortGroupForUpdate.FinishDate, cohortGroupForUpdate.ConditionName); _logger.LogInformation( "----- Sending command: AddCohortGroupCommand - {cohortName}", command.CohortName); var commandResult = await _mediator.Send(command); if (commandResult == null) { return(BadRequest("Command not created")); } return(CreatedAtAction("GetCohortGroupByDetail", new { id = commandResult.Id }, commandResult)); }
public async Task <IActionResult> UpdateCohortGroup(int id, [FromBody] CohortGroupForUpdateDto cohortGroupForUpdate) { if (cohortGroupForUpdate == null) { ModelState.AddModelError("Message", "Unable to locate payload for new request"); } var command = new ChangeCohortGroupDetailsCommand(id, cohortGroupForUpdate.CohortName, cohortGroupForUpdate.CohortCode, cohortGroupForUpdate.StartDate, cohortGroupForUpdate.FinishDate, cohortGroupForUpdate.ConditionName); _logger.LogInformation( "----- Sending command: ChangeCohortGroupDetailsCommand - {Id}", command.Id); var commandResult = await _mediator.Send(command); if (!commandResult) { return(BadRequest("Command not created")); } return(Ok()); }