Last change
on this file was a569b7c, checked in by Danilo <danilo.najkov@…>, 2 years ago |
todo items full functionality
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Line | |
---|
1 | namespace backend.Controllers;
|
---|
2 |
|
---|
3 | using backend.DTOs;
|
---|
4 | using backend.Entities;
|
---|
5 | using backend.Helpers;
|
---|
6 | using backend.Models;
|
---|
7 | using backend.Services;
|
---|
8 | using Microsoft.AspNetCore.Mvc;
|
---|
9 | using System.Security.Claims;
|
---|
10 |
|
---|
11 | [ApiController]
|
---|
12 | [Route("[controller]")]
|
---|
13 | public class ToDoController : ControllerBase
|
---|
14 | {
|
---|
15 | private readonly IToDoService _toDoService = null;
|
---|
16 |
|
---|
17 | public ToDoController(IToDoService todoService)
|
---|
18 | {
|
---|
19 | _toDoService = todoService;
|
---|
20 | }
|
---|
21 |
|
---|
22 | [Authorize]
|
---|
23 | [HttpPost()]
|
---|
24 | public async Task<IActionResult> CreateToDoItem([FromBody] CreateToDoItemRequest req)
|
---|
25 | {
|
---|
26 | await _toDoService.AddNewToDoItem(req);
|
---|
27 | return Ok();
|
---|
28 | }
|
---|
29 |
|
---|
30 | [Authorize]
|
---|
31 | [HttpGet()]
|
---|
32 | public async Task<List<ToDoItemResponse>> GetToDoItems(string sortBy)
|
---|
33 | {
|
---|
34 | return await _toDoService.GetToDoItems(sortBy);
|
---|
35 | }
|
---|
36 |
|
---|
37 | [Authorize]
|
---|
38 | [HttpPut("{id}")]
|
---|
39 | public async Task<IActionResult> UpdateToDoStatus(int id, ToDoStatus newStatus)
|
---|
40 | {
|
---|
41 | await _toDoService.UpdateToDoItemStatus(id, newStatus);
|
---|
42 | return Ok();
|
---|
43 | }
|
---|
44 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.