//Gets a review from a specific user on a tape
        //Throws exception if either user id or tape id are invalid
        public ReviewDTO GetUserReviewForTape(int userId, int tapeId)
        {
            var user   = _userService.IsValidId(userId);
            var tape   = _tapeService.IsValidId(tapeId);
            var review = _repository.GetUserReviewForTape(userId, tapeId);

            if (review == null)
            {
                throw new ResourceNotFoundException($"Review for user {userId} and tape {tapeId} does not exist!");
            }
            return(Mapper.Map <ReviewDTO>(review));
        }
Example #2
0
        // user/userId/tapes/tapeId: Register new loan
        public void RegisterTapeOnLoan(int userId, int tapeId)
        {
            var user      = _userService.IsValidId(userId);
            var tape      = _tapeService.IsValidId(tapeId);
            var checkLoan = CheckIfTapeIsBorrowed(tapeId);

            if (checkLoan != null)
            {
                throw new LoanException($"Tape with id {tapeId} is currently loaned");
            }
            // if (CheckIfTapeIsBorrowed(tapeId) != null) { throw new LoanException($"Tape with id {tapeId} is currently loaned"); }
            var allLoans = _repository.GetAllLoans();

            _repository.RegisterTapeOnLoan(userId, tapeId);
        }