source: resTools_backend/backend/Controllers/ReservationsController.cs@ d76b7ee

Last change on this file since d76b7ee was d76b7ee, checked in by Danilo <danilo.najkov@…>, 3 years ago

prototype final

  • Property mode set to 100644
File size: 1.2 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 ReservationsController : ControllerBase
14{
15 private readonly IReservationService _reservationService = null;
16
17 public ReservationsController(IReservationService reservationService)
18 {
19 _reservationService = reservationService;
20 }
21
22 [Authorize]
23 [HttpGet()]
24 public async Task<List<ReservationResponse>> GetReservations([FromQuery] DateTime from, [FromQuery] DateTime to)
25 {
26 return await _reservationService.GetReservatins(from, to);
27 }
28
29 [HttpPost()]
30 public async Task<IActionResult> CreateReservation([FromBody] CreateReservationRequest req)
31 {
32 await _reservationService.CreateReservation(req);
33 return Ok();
34 }
35
36 [Authorize]
37 [HttpPut("{rid}")]
38 public async Task<IActionResult> ChangeStatus(int rid, [FromQuery] ReservationStatus status)
39 {
40 await _reservationService.ChangeReservationStatus(rid, status);
41 return Ok();
42 }
43}
Note: See TracBrowser for help on using the repository browser.