Example #1
0
        public async Task <IActionResult> CloseQuestionAsync([FromBody] CloseQuestionDTO closeQuestionDTO)
        {
            try
            {
                var command = new CloseQuestionCommand
                {
                    QuestionId = closeQuestionDTO.QuestionId,
                    Token      = closeQuestionDTO.Token
                };

                var closeQuestionResult = await QuestionService.CloseQuestionAsync(command);

                var result = Mapper.Map <CloseQuestionResult, CloseQuestionResultDTO>(closeQuestionResult);

                return(Ok(result));
            }
            catch (Exception exception)
            {
                return(Exception(exception, "Failed to close question"));
            }
        }
        public async Task <IActionResult> Close([FromQuery] Guid questionId, [FromQuery] string token)
        {
            CloseQuestionCommand command = new CloseQuestionCommand()
            {
                QuestionId = questionId,
                Token      = token
            };

            var result = await QuestionService.CloseQuestionAsync(command);

            if (result.Succeeded)
            {
                ViewBag.Result = "Closed";
            }
            else
            {
                ViewBag.Result = "Failed";
            }

            return(View("Result"));
        }