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
|
Rev | Line | |
---|
[057037b] | 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 | }
|
---|
[cc4db18] | 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 | }
|
---|
[057037b] | 54 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.