public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Book).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BookExists(Book.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./IndexBooks")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Genre.Add(Genre); await _context.SaveChangesAsync(); return(RedirectToPage("./IndexGenres")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.FavouriteBook.Add(FavouriteBook); await _context.SaveChangesAsync(); return(RedirectToPage("../FavBooks/Index")); }
public async Task <IActionResult> OnGetAsync(int?bookId) { if (bookId == null) { return(NotFound()); } var userId = _userManager.GetUserId(HttpContext.User); var Book = _context.FavBook.FindAsync(bookId, userId); // pobieranie ksiazki, ktora chcesz usunac (z favBooks) _context.Remove(Book); await _context.SaveChangesAsync(); return(RedirectToPage("Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Book = await _context.Book.FindAsync(id); if (Book != null) { _context.Book.Remove(Book); await _context.SaveChangesAsync(); } return(RedirectToPage("./IndexBooks")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Genre = await _context.Genre.FindAsync(id); if (Genre != null) { _context.Genre.Remove(Genre); await _context.SaveChangesAsync(); } return(RedirectToPage("./IndexGenres")); }