コード例 #1
0
        public async Task <IActionResult> PostAnswer([FromBody] AnswerModelWrapper answerModel)
        {
            if (!this.IsTokenValid(_tokenService.GetTemporaryToken(this.GetCurrentUserId())))
            {
                return(Unauthorized());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var command = await _mediator.Send(new BulkAnswers(answerModel.Answers));

            command.UserId         = this.GetCurrentUserId();
            command.CompletionDate = answerModel.CompletionDate;
            command.FormId         = answerModel.FormId;

            var result = await _mediator.Send(command);

            if (result < 0)
            {
                return(NotFound());
            }

            return(Ok());
        }
コード例 #2
0
        public async Task <IActionResult> PostAnswer([FromBody] AnswerModelWrapper answerModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            // TODO[DH] use a pipeline instead of separate Send commands
            var command = await _mediator.Send(new BulkAnswers(answerModel.Answers));

            command.ObserverId = this.GetIdObserver();

            var result = await _mediator.Send(command);

            if (result < 0)
            {
                return(NotFound());
            }

            return(Ok());
        }