Beispiel #1
0
        public async Task <ActionResult> SaveSurvey([FromBody] SaveSurveyViewModel survey)
        {
            if (survey == null)
            {
                return(BadRequest("survey not specified"));
            }

            var command = new UpdateSurveyCommand()
            {
                Survey = new Survey()
                {
                    Id                    = survey.SurveyId,
                    Title                 = survey.SurveyName,
                    Description           = survey.Description,
                    Questions             = survey.QuestionDefinitions,
                    SurveyPassAccessLevel = (SurveyPassAccessLevel)survey.Access
                }
            };

            CommandResult result = await _commandDispatcher.ExecuteAsync(command);

            if (result.IsSuccess)
            {
                return(Ok(new OkServiceResponse <string>("saved")));
            }

            if (result.Error != null)
            {
                return(BadRequest(new ErrorServiceRespose(result.Error)));
            }

            return(BadRequest(new ErrorServiceRespose("Unexpected error")));
        }
Beispiel #2
0
        public async Task <ActionResult <IActionResult> > Update([FromBody] UpdateSurveyCommand command)
        {
            await Mediator.Send(command);

            return(NoContent());
        }