Ejemplo n.º 1
0
        private async void UpdateItem()
        {
            var idText   = TBUpdateItemId.Text;
            var value    = TBUpdateItemValue.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)CBUpdateItemCategory.SelectedItem;
            string       category = typeItem.Content.ToString();

            ComboBoxItem typeItem2 = (ComboBoxItem)CBUpdateItemType.SelectedItem;
            string       type      = typeItem2.Content.ToString();

            if (category == T26.Content.ToString()) //Books
            {
                BookProcessor book = new BookProcessor();
                response = await book.UpdateBook(id, type, value);

                MessageBox.Show(response.Info);
            }
            else
            if (category == T27.Content.ToString()) //Newspapers
            {
                NewspaperProcessor newspaper = new NewspaperProcessor();
                response = await newspaper.UpdateNewspaper(id, type, value);

                MessageBox.Show(response.Info);
            }
            else
            if (category == T28.Content.ToString()) //Journals
            {
                JournalProcessor journal = new JournalProcessor();
                response = await journal.UpdateJournal(id, type, value);

                MessageBox.Show(response.Info);
            }
            else
            if (category == T29.Content.ToString()) //Magazines
            {
                MagazineProcessor magazine = new MagazineProcessor();
                response = await magazine.UpdateMagazine(id, type, value);

                MessageBox.Show(response.Info);
            }
            else
            if (category == T30.Content.ToString()) //Manuscripts
            {
                ManuscriptProcessor manuscript = new ManuscriptProcessor();
                response = await manuscript.UpdateManuscript(id, type, value);

                MessageBox.Show(response.Info);
            }
        }