예제 #1
0
        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"));
 }
예제 #3
0
        public static void DeleteOne()
        {
            var bookRepo = new BooksRepository();
            var book     = bookRepo.FindBy(b => b.Id == 11).FirstOrDefault();

            bookRepo.Delete(book);
            bookRepo.Save();
        }
예제 #4
0
        internal bool Delete(int id)
        {
            Book foundBook = GetById(id);

            if (foundBook == null)
            {
                throw new Exception("Book not found.");
            }
            return(_repo.Delete(id));
        }
예제 #5
0
        // NOTE Delete Request
        internal Book Delete(int id)
        {
            Book foundBook = GetById(id);

            if (_repo.Delete(id))
            {
                return(foundBook);
            }
            throw new Exception("Invalid ID");
        }
예제 #6
0
        internal Book Delete(int id)
        {
            Book foundBook = GetById(id);

            if (_repo.Delete(id))
            {
                return(foundBook);
            }
            throw new Exception("Something bad happened...");
        }
예제 #7
0
        //books/delete/15
        public ActionResult Delete(int id)
        {
            BooksRepository r = new BooksRepository();

            r.Delete(id);
            List <BookModel> myBooks = r.GetAll();



            return(View("List", myBooks));
        }
예제 #8
0
        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());
        }
예제 #9
0
        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.");
        }
예제 #10
0
        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));
            }
        }
예제 #12
0
        //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));
        }
예제 #13
0
 public ActionResult Delete(Guid id)
 {
     _booksRepository.Delete(id);
     return(Json(true));
 }
예제 #14
0
        // DELETE: api/Books/5
        public bool Delete(int id)
        {
            BooksRepository booksRepo = new BooksRepository();

            return(booksRepo.Delete(id));
        }
예제 #15
0
 public int Delete(Book _Book)
 {
     return(_BooksRepository.Delete(_Book));
 }
예제 #16
0
        public string Delete(int bookId)
        {
            var message = _bookRepository.Delete(bookId);

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