コード例 #1
0
        public async Task <ActionResult <Book> > DeleteBook(int id)
        {
            var book = await _DBContext.Books.FindAsync(id);

            if (book == null)
            {
                return(NotFound());
            }

            if (!string.IsNullOrEmpty(book.GUID))
            {
                ImageUpload.DeleteFile(book.GUID);  //Delete image from static folder
            }
            _DBContext.Books.Remove(book);
            await _DBContext.SaveChangesAsync();

            return(book);
        }