source: backend/Controllers/RestaurantsController.cs@ 057037b

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

backend full

  • Property mode set to 100644
File size: 957 bytes
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}
Note: See TracBrowser for help on using the repository browser.