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

            bookRepo.Delete(book);
            bookRepo.Save();
        }
Ejemplo n.º 4
0
        internal bool Delete(int id)
        {
            Book foundBook = GetById(id);

            if (foundBook == null)
            {
                throw new Exception("Book not found.");
            }
            return(_repo.Delete(id));
        }
Ejemplo n.º 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");
        }
Ejemplo n.º 6
0
        internal Book Delete(int id)
        {
            Book foundBook = GetById(id);

            if (_repo.Delete(id))
            {
                return(foundBook);
            }
            throw new Exception("Something bad happened...");
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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.");
        }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 13
0
 public ActionResult Delete(Guid id)
 {
     _booksRepository.Delete(id);
     return(Json(true));
 }
Ejemplo n.º 14
0
        // DELETE: api/Books/5
        public bool Delete(int id)
        {
            BooksRepository booksRepo = new BooksRepository();

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

            return(message);
        }
Ejemplo n.º 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");
        }