source: resTools_backend/backend/Controllers/RestaurantsController.cs@ cc4db18

Last change on this file since cc4db18 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.3 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 RestaurantsController : ControllerBase
14{
15 private readonly IRestaurantService _restaurantService = null;
16
17 public RestaurantsController(IRestaurantService restaurantService)
18 {
19 _restaurantService = restaurantService;
20 }
21
22 [Authorize]
23 [HttpPost()]
24 public async Task<IActionResult> CreateRestaurant([FromQuery] string title)
25 {
26 var userId = (int) this.HttpContext.Items["User"];
27 await _restaurantService.CreateRestaurant(title, userId);
28
29
30 return Ok();
31 }
32
33 [HttpGet()]
34 public async Task<RestaurantResponse> GetRestaurant()
35 {
36 var response = await _restaurantService.GetRestaurant();
37 return response;
38 }
39
40 [HttpPost("upload")]
41 public async Task<IActionResult> UploadImage([FromForm] IFormFile file)
42 {
43 await _restaurantService.UploadImage(file);
44 return Ok();
45 }
46
47 [Authorize]
48 [HttpPut()]
49 public async Task<IActionResult> UpdateRestaurant([FromBody] UpdateRestaurantRequest req)
50 {
51 await _restaurantService.UpdateRestaurant(req);
52 return Ok();
53 }
54}
Note: See TracBrowser for help on using the repository browser.