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
|
Rev | Line | |
---|
[846cf1a] | 1 | using FinkiChattery.Api.ApplicationServices.Authentication;
|
---|
| 2 | using FinkiChattery.Commands.Questioning;
|
---|
| 3 | using FinkiChattery.Common.Mediator.Interfaces;
|
---|
| 4 | using FinkiChattery.Contracts.Questioning;
|
---|
| 5 | using IdentityServer4.AccessTokenValidation;
|
---|
| 6 | using Microsoft.AspNetCore.Authorization;
|
---|
| 7 | using Microsoft.AspNetCore.Mvc;
|
---|
| 8 | using System;
|
---|
| 9 | using System.Threading.Tasks;
|
---|
| 10 |
|
---|
| 11 | namespace 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.