source: resTools_backend/backend/Controllers/ReservationsController.cs

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

reservation module changes + contact module + menu module

  • Property mode set to 100644
File size: 1.6 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 [Authorize]
30 [HttpGet("new")]
31 public async Task<List<ReservationResponse>> GetReservationsNew()
32 {
33 return await _reservationService.GetNewReservations();
34 }
35
36 [HttpPost()]
37 public async Task<IActionResult> CreateReservation([FromBody] CreateReservationRequest req)
38 {
39 await _reservationService.CreateReservation(req);
40 return Ok();
41 }
42
43 [Authorize]
44 [HttpPut("{rid}/status")]
45 public async Task<IActionResult> ChangeStatus(int rid, [FromQuery] ReservationStatus status)
46 {
47 await _reservationService.ChangeReservationStatus(rid, status);
48 return Ok();
49 }
50
51 [Authorize]
52 [HttpPut("{rid}/table")]
53 public async Task<IActionResult> ChangeTable(int rid, [FromQuery] int tableId)
54 {
55 await _reservationService.AssignTable(tableId, rid);
56 return Ok();
57 }
58}
Note: See TracBrowser for help on using the repository browser.