Ignore:
Timestamp:
09/18/22 18:09:53 (2 years ago)
Author:
Danilo <danilo.najkov@…>
Branches:
master
Parents:
49b0bbd
Message:

vip functionallity + menu fields + alergens filtering + google/fb login + email queueing

Location:
resTools_backend/backend/Controllers
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • resTools_backend/backend/Controllers/MenuController.cs

    r49b0bbd r13f1472  
    3535        return Ok();
    3636    }
     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    }
    3744}
  • resTools_backend/backend/Controllers/ReviewsController.cs

    r49b0bbd r13f1472  
    1212    {
    1313        private readonly IReviewService _reviewService = null;
     14        private readonly IUserService _userService = null;
    1415
    15         public ReviewsController(IReviewService reviewService)
     16        public ReviewsController(IReviewService reviewService, IUserService userService)
    1617        {
    1718            _reviewService = reviewService;
     19            _userService = userService;
    1820        }
    1921
     
    3941                userId = (int)this.HttpContext.Items["User"];
    4042            }
    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            }
    4251            await _reviewService.AddReview(req, userId);
    4352            return Ok();
  • resTools_backend/backend/Controllers/UsersController.cs

    r49b0bbd r13f1472  
    3939        {
    4040            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        }
    4251        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};
    4453    }
    4554
     
    93102        return response;
    94103    }
     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    }
    95118}
Note: See TracChangeset for help on using the changeset viewer.