Last change
on this file since d76b7ee was 7a983b0, checked in by Danilo <danilo.najkov@…>, 3 years ago |
move files
|
-
Property mode
set to
100644
|
File size:
957 bytes
|
Line | |
---|
1 | namespace backend.Controllers;
|
---|
2 |
|
---|
3 | using backend.DTOs;
|
---|
4 | using backend.Entities;
|
---|
5 | using backend.Helpers;
|
---|
6 | using backend.Models;
|
---|
7 | using backend.Services;
|
---|
8 | using Microsoft.AspNetCore.Mvc;
|
---|
9 | using System.Security.Claims;
|
---|
10 |
|
---|
11 | [ApiController]
|
---|
12 | [Route("[controller]")]
|
---|
13 | public 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.