private void BtnDeleteBook_Click(object sender, EventArgs e) { if (bookBindingSource.Current != null) { if (MessageBox.Show("Вы действительно хотите удалить запись?", "Сообщение", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { var relatedIssuedBooks = issuedBooksRepository.GetAll() .Where(b => b.IdBook == ((Book)bookBindingSource.Current).Id).ToList(); if (relatedIssuedBooks.Any()) { if (MessageBox.Show( String.Format( "Чтобы удалить эту книгу, нужно удалить все выданные книги ({0} записей) связанные с ней." + " " + "Хотите продожить?", relatedIssuedBooks.Count), "Сообщение", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK) { return; } } booksRepository.Delete((Book)bookBindingSource.Current); bookBindingSource.RemoveCurrent(); issuedBooksBindingSource.DataSource = ((ICanGetAll <IssuedBookView>)issuedBooksRepository).GetAll(); } } }
public ActionResult Delete(int?id) { if (id != null) { books.Delete((int)id); } return(RedirectToAction("List")); }
public static void DeleteOne() { var bookRepo = new BooksRepository(); var book = bookRepo.FindBy(b => b.Id == 11).FirstOrDefault(); bookRepo.Delete(book); bookRepo.Save(); }
internal bool Delete(int id) { Book foundBook = GetById(id); if (foundBook == null) { throw new Exception("Book not found."); } return(_repo.Delete(id)); }
// NOTE Delete Request internal Book Delete(int id) { Book foundBook = GetById(id); if (_repo.Delete(id)) { return(foundBook); } throw new Exception("Invalid ID"); }
internal Book Delete(int id) { Book foundBook = GetById(id); if (_repo.Delete(id)) { return(foundBook); } throw new Exception("Something bad happened..."); }
//books/delete/15 public ActionResult Delete(int id) { BooksRepository r = new BooksRepository(); r.Delete(id); List <BookModel> myBooks = r.GetAll(); return(View("List", myBooks)); }
public async Task <ActionResult> Delete(int id) { var books = await _booksRepository.GetById(id); if (books == null) { return(NotFound()); } await _booksRepository.Delete(id, books); return(Ok()); }
public string Delete(int id) { Book exists = _repo.Get(id); if (exists == null) { throw new Exception("Invalid Id"); } if (_repo.Delete(id)) { return("Success"); } throw new Exception("Something went wrong with deleting that item."); }
public ActionResult DeleteBook(BooksDeleteBookVM model) { LibraryManagementSystemContext context = new LibraryManagementSystemContext(); BooksRepository booksRepository = new BooksRepository(context); Book book = booksRepository.GetByID(model.ID); if (book == null) { return(HttpNotFound()); } else { booksRepository.Delete(book); } return(RedirectToAction("Index")); }
//DELETE: api/Books/5 public IHttpActionResult Delete([FromUri] int id) { try { var booksRepository = new BooksRepository(); var deleteBook = booksRepository.Delete(id); if (deleteBook == null) { return(NotFound()); } return(StatusCode(HttpStatusCode.NoContent)); } catch (Exception ex) { return(InternalServerError(ex)); } }
//public ActionResult Delete( BookModel book) //{ // BooksRepository r = new BooksRepository(); // for (int i = 0; i <= listaCarti.Count - 1; i++) // { // if (book.Id == listaCarti[i].Id) // { // listaCarti.Remove(listaCarti[i]); // } // } // return View("Succes2"); //} public ActionResult Delete(int id) { //var b1 = listaCarti.Find(x => x.Id == id); //listaCarti.Remove(b1); BooksRepository r = new BooksRepository(); r.Delete(id); List <BookModel> myBooks = r.GetAll(); // foreach (BookModel book in listaCarti) // { // if (book.Id == id) // { // listaCarti.RemoveAt(id); // return View("List", listaCarti); // } // } return(View("List", myBooks)); }
public ActionResult Delete(Guid id) { _booksRepository.Delete(id); return(Json(true)); }
// DELETE: api/Books/5 public bool Delete(int id) { BooksRepository booksRepo = new BooksRepository(); return(booksRepo.Delete(id)); }
public int Delete(Book _Book) { return(_BooksRepository.Delete(_Book)); }
public string Delete(int bookId) { var message = _bookRepository.Delete(bookId); return(message); }
public ActionResult DeleteConfirmed(int id) { booksRepository.Delete(id); return(RedirectToAction(nameof(Index))); }
public ActionResult DeleteBook(BooksDeleteBookVM model) { LibraryManagementSystemContext context = new LibraryManagementSystemContext(); BooksRepository booksRepository = new BooksRepository(context); Book book = booksRepository.GetByID(model.ID); if (book == null) { return HttpNotFound(); } else { booksRepository.Delete(book); } return RedirectToAction("Index"); }