source: src/FinkiChattery/FinkiChattery.Api/Controllers/v1/AnswersController.cs@ 80e2fe0

dev
Last change on this file since 80e2fe0 was 846cf1a, checked in by Стојков Марко <mst@…>, 3 years ago

Answer question endpoint

  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[846cf1a]1using FinkiChattery.Api.ApplicationServices.Authentication;
2using FinkiChattery.Commands.Questioning;
3using FinkiChattery.Common.Mediator.Interfaces;
4using FinkiChattery.Contracts.Questioning;
5using IdentityServer4.AccessTokenValidation;
6using Microsoft.AspNetCore.Authorization;
7using Microsoft.AspNetCore.Mvc;
8using System;
9using System.Threading.Tasks;
10
11namespace FinkiChattery.Api.Controllers.v1
12{
13 [ApiVersion(ApiVersions.ApiVersion1)]
14 [Route("api/v{version:apiVersion}/questions/{questionUid:Guid}/[controller]/")]
15 [ApiController]
16 public class AnswersController : ControllerBase
17 {
18 public AnswersController(IMediatorService mediatorService)
19 {
20 MediatorService = mediatorService;
21 }
22
23 public IMediatorService MediatorService { get; }
24
25 [HttpPost]
26 [Authorize(AuthenticationSchemes = IdentityServerAuthenticationDefaults.AuthenticationScheme, Policy = AuthenticationPolicy.Student)]
27 public async Task<IActionResult> AnswerQuestion([FromRoute] Guid questionUid, [FromBody] AnswerQuestionRequest request)
28 {
29 var answerUid = await MediatorService.SendAsync(new AnswerQuestionCommand(questionUid, request.Text));
30 return Ok(answerUid);
31 }
32 }
33}
Note: See TracBrowser for help on using the repository browser.