예제 #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());
        }
예제 #2
0
        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"));
        }
예제 #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());
        }