Пример #1
0
        public void DeleteTapeById_ReturnsNothing()
        {
            // act & assert
            Assert.AreEqual(2, repository.GetAllTapes().Count());
            var tape = repository.GetTapeById(1);

            repository.DeleteTape(tape);
            Assert.AreEqual(1, repository.GetAllTapes().Count());
            Assert.AreEqual(true, tape.Deleted);
        }
Пример #2
0
        /// <summary>
        /// Deletes tape, throws resource not found exception if no tape is associated to Id
        /// </summary>
        /// <param name="Id">Id associated with tape in system to delete</param>
        public void DeleteTape(int Id)
        {
            var tape = _tapeRepository.GetAllTapes().FirstOrDefault(t => t.Id == Id);

            if (tape == null)
            {
                throw new ResourceNotFoundException($"Video tape with id {Id} was not found.");
            }
            else
            {
                RemoveBorrowRecordsFromTape(Id);
                RemoveReviewsFromTape(Id);
                _tapeRepository.DeleteTape(Id);
            }
        }
Пример #3
0
 public void DeleteTape(int id)
 {
     _tapeRepository.DeleteTape(id);
 }
        //Delete a valid tape, call the delete function from the repository
        //Throws exception if tape id is invalid
        public void DeleteTape(int tapeId)
        {
            var tape = IsValidId(tapeId);

            _tapeRepository.DeleteTape(tape);
        }