public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Author).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AuthorExists(Author.AuthorId)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { //Book.author = _context.Author.Where(a => a.AuthorId == Book.AuthorId).FirstOrDefault(); //if (!ModelState.IsValid) //{ // return Page(); //} _context.Book.Add(Book); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(Guid?id) { if (id == null) { return(NotFound()); } Book = await _context.Book.FindAsync(id); if (Book != null) { _context.Book.Remove(Book); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } try { _context.Author.Add(Author); await _context.SaveChangesAsync(); } catch { return(RedirectToPage("../Error")); } //_context.Author.Add(Author); //await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }