Changeset 13f1472 for resTools_backend/backend/Controllers
- Timestamp:
- 09/18/22 18:09:53 (2 years ago)
- Branches:
- master
- Parents:
- 49b0bbd
- Location:
- resTools_backend/backend/Controllers
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
resTools_backend/backend/Controllers/MenuController.cs
r49b0bbd r13f1472 35 35 return Ok(); 36 36 } 37 38 [HttpPost("{id}/upload")] 39 public async Task<IActionResult> UploadImage(int id, [FromForm] IFormFile file) 40 { 41 await _menuService.UploadImage(id, file); 42 return Ok(); 43 } 37 44 } -
resTools_backend/backend/Controllers/ReviewsController.cs
r49b0bbd r13f1472 12 12 { 13 13 private readonly IReviewService _reviewService = null; 14 private readonly IUserService _userService = null; 14 15 15 public ReviewsController(IReviewService reviewService )16 public ReviewsController(IReviewService reviewService, IUserService userService) 16 17 { 17 18 _reviewService = reviewService; 19 _userService = userService; 18 20 } 19 21 … … 39 41 userId = (int)this.HttpContext.Items["User"]; 40 42 } 41 catch (Exception ex) { return null; } 43 catch (Exception ex) { 44 var user = await _userService.GetByEmail((string)this.HttpContext.Items["User"]); 45 if (user == null) 46 { 47 return null; 48 } 49 userId = user.Id; 50 } 42 51 await _reviewService.AddReview(req, userId); 43 52 return Ok(); -
resTools_backend/backend/Controllers/UsersController.cs
r49b0bbd r13f1472 39 39 { 40 40 userId = (int)this.HttpContext.Items["User"]; 41 }catch (Exception ex){ return null; } 41 } 42 catch (Exception ex) 43 { 44 var usr = await _userService.GetByEmail((string)this.HttpContext.Items["User"]); 45 if(usr == null) 46 { 47 return null; 48 } 49 userId = usr.Id; 50 } 42 51 User user = await _userService.GetById(userId); 43 return new AuthenticateResponse() { Email=user.Email, Id = user.Id, IsAdmin = user.IsAdmin, IsConfirmed = user.IsConfirmed };52 return new AuthenticateResponse() { Email=user.Email, Id = user.Id, IsAdmin = user.IsAdmin, IsConfirmed = user.IsConfirmed, isVip = user.IsVip}; 44 53 } 45 54 … … 93 102 return response; 94 103 } 104 105 [Authorize] 106 [HttpGet()] 107 public async Task<List<UserResponse>> GetUsers() 108 { 109 return await _userService.GetUsers(); 110 } 111 112 [Authorize] 113 [HttpPost("{id}/vip")] 114 public async Task UpdateVip(int id, bool newStatus) 115 { 116 await _userService.UpdateVipStatus(id,newStatus); 117 } 95 118 }
Note:
See TracChangeset
for help on using the changeset viewer.