Beispiel #1
0
        public void DeleteAsync_InvalidId_Throw()
        {
            var bookId = Guid.NewGuid();

            _booksRepository.Setup(br => br.RemoveAsync(bookId)).ReturnsAsync(false);

            Assert.ThrowsAsync <BookNotFoundException>(async() => await _booksService.DeleteAsync(bookId));
            _booksRepository.Verify(br => br.RemoveAsync(bookId));
            _unitOfWork.Verify(uow => uow.SaveAsync(), Times.Never);
        }
        public IActionResult Delete(int id)
        {
            var getProd = _BookService.GetAsync(id);

            if (getProd.Result != null)
            {
                _BookService.DeleteAsync(getProd.Result);
            }

            return(Ok());
        }
        public async Task <IActionResult> DeleteAsync(int id)
        {
            await _booksService.DeleteAsync(id);

            return(NoContent());
        }
Beispiel #4
0
        public async Task <IActionResult> DeleteAsync([FromRoute] Guid bookId)
        {
            await _booksService.DeleteAsync(bookId);

            return(Ok());
        }