source: resTools_backend/backend/Controllers/ToDoController.cs

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 
1namespace backend.Controllers;
2
3using backend.DTOs;
4using backend.Entities;
5using backend.Helpers;
6using backend.Models;
7using backend.Services;
8using Microsoft.AspNetCore.Mvc;
9using System.Security.Claims;
10
11[ApiController]
12[Route("[controller]")]
13public 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.