Example #1
0
        private async void DeleteItem()
        {
            var idText   = TBDeleteItemId.Text;
            var response = new AuthResponseModel();
            int id;

            if (!Regex.IsMatch(idText, @"^\d+$"))
            {
                MessageBox.Show("ID should be a number!");
                return;
            }
            else
            {
                id = Convert.ToInt32(idText);
            }

            ComboBoxItem typeItem = (ComboBoxItem)CBDeleteItemCategory.SelectedItem;
            string       category = typeItem.Content.ToString();

            if (category == T31.Content.ToString()) //Books
            {
                BookProcessor book = new BookProcessor();
                response = await book.DeleteBook(id);

                MessageBox.Show(response.Info);
            }
            else
            if (category == T32.Content.ToString()) //Newspapers
            {
                NewspaperProcessor newspaper = new NewspaperProcessor();
                response = await newspaper.DeleteNewspaper(id);

                MessageBox.Show(response.Info);
            }
            else
            if (category == T33.Content.ToString()) //Journals
            {
                JournalProcessor journal = new JournalProcessor();
                response = await journal.DeleteJournal(id);

                MessageBox.Show(response.Info);
            }
            else
            if (category == T34.Content.ToString()) //Magazines
            {
                MagazineProcessor magazine = new MagazineProcessor();
                response = await magazine.DeleteMagazine(id);

                MessageBox.Show(response.Info);
            }
            else
            if (category == T35.Content.ToString()) //Manuscripts
            {
                ManuscriptProcessor manuscript = new ManuscriptProcessor();
                response = await manuscript.DeleteManuscript(id);

                MessageBox.Show(response.Info);
            }
        }
Example #2
0
 public bool DeleteBook(int id)
 {
     return(BookProcessor.DeleteBook(id));
 }
        public ActionResult Delete(int id)
        {
            int booksDeleted = BookProcessor.DeleteBook(id);

            return(RedirectToAction("Cart"));
        }