Exemplo n.º 1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.MyBook.Add(MyBook);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

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

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

            return(RedirectToPage("./Index"));
        }