Exemple #1
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Books = await _context.Books
                    .Include(b => b.Author)
                    .Include(b => b.Category).FirstOrDefaultAsync(m => m.Id == id);

            if (Books == null)
            {
                return(NotFound());
            }
            return(Page());
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Books = await _context.Books.FindAsync(id);

            if (Books != null)
            {
                _context.Books.Remove(Books);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Exemple #3
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Books = await _context.Books
                    .Include(b => b.Author)
                    .Include(b => b.Category).FirstOrDefaultAsync(m => m.Id == id);

            if (Books == null)
            {
                return(NotFound());
            }
            ViewData["AuthorId"]   = new SelectList(_context.Authors, "Id", "Id");
            ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Id");
            return(Page());
        }