public IActionResult AddForm(BookVM book)
        {
            book.genreList  = _genreRepo.GetAllGenres();
            book.authorList = _authorRepo.GetAllAuthors();

            return(View("AddForm", book));
        }
 public bool SetData()
 {
     if (_genreRepo.GetAllGenres().Count == 0)
     {
         MessageBox.Show("No genre has been added yet", "Genre not exists error", MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
         btnDelete.Enabled       = false;
         genreTextBox.Text       = "";
         descriptionTextBox.Text = "";
     }
     if (_genreRepo.GetAllGenres().Count <= _index || _index < 0)
     {
         return(false);
     }
     genreTextBox.Text       = _genreRepo.GetAllGenres()[_index].Name;
     descriptionTextBox.Text = _genreRepo.GetAllGenres()[_index].Description;
     return(true);
 }
Exemple #3
0
        public void SearcSubsGenres(string url)
        {
            genresDb = repo.GetAllGenres();

            foreach (var item in genresDb)
            {
                LookSubGenres(url, item.ShortCut, item.GenreId);
            }
        }
Exemple #4
0
        private void StartingPoint()
        {
            genreCombo.SelectedIndex     = -1;
            publisherCombo.SelectedIndex = -1;
            authorCombo.SelectedIndex    = -1;
            titleTextBox.Text            = "";
            numberTextBox.Text           = "";
            copiesTextBox.Text           = "";
            if (!_firstIteration)
            {
                return;
            }
            var allGenres     = _genreRepo.GetAllGenres();
            var allPublishers = _publisherRepo.GetAllPublisher();
            var allAuthors    = _authorRepo.GetAllAuthors();

            if (allGenres.Count == 0)
            {
                MessageBox.Show("There's no genres to choose from, make sure to add genres before adding book types.", "Genres not exist error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                btnSave.Enabled = false;
            }
            foreach (var genre in allGenres)
            {
                genreCombo.Items.Add(genre.Name);
            }

            if (allPublishers.Count == 0)
            {
                MessageBox.Show("There's no publishers to choose from, make sure to add publishers before adding book types", "Publisher not exist error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                btnSave.Enabled = false;
            }
            foreach (var publisher in allPublishers)
            {
                publisherCombo.Items.Add(publisher.Name);
            }

            if (allAuthors.Count == 0)
            {
                MessageBox.Show("There's no authors to choose from, make sure to add authors before adding book types", "Author not exist error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                btnSave.Enabled = false;
            }
            foreach (var author in allAuthors)
            {
                authorCombo.Items.Add(author.AuthorPerson.Name + " " + author.AuthorPerson.Surname);
            }
            _firstIteration = false;
        }
Exemple #5
0
        public ActionResult <Genre> Genres()
        {
            var genre = genreRepo.GetAllGenres();

            for (int j = 0; j < genre.Count; j++)
            {
                genre[j].SubGenre = genreRepo.GetSubGenreByGenre(genre[j].GenreId).Select(x => x.ShortCut).ToList();
            }

            if (genre == null)
            {
                NotFound();
            }
            return(Ok(genre));
        }
        public bool SetData()
        {
            if (_firstIteration)
            {
                foreach (var genre in _genreRepo.GetAllGenres())
                {
                    genreCombo.Items.Add(genre.Name);
                }

                foreach (var publisher in _publisherRepo.GetAllPublisher())
                {
                    publisherCombo.Items.Add(publisher.Name);
                }

                foreach (var author in _authorRepo.GetAllAuthors())
                {
                    authorCombo.Items.Add(author.AuthorPerson.Name + " " + author.AuthorPerson.Surname);
                }
                _firstIteration = false;
            }
            if (_typeBook.GetAllBookTypes().Count == 0)
            {
                MessageBox.Show("No books have been added yet", "Book not exists error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                titleTextBox.Text   = "";
                numberTextBox.Text  = "";
                genreCombo.Text     = "";
                authorCombo.Text    = "";
                publisherCombo.Text = "";
                publisherCombo.Text = "";
                copiesTextBox.Text  = "";
                btnSave.Enabled     = false;
            }
            if (_typeBook.GetAllBookTypes().Count <= _index || _index < 0)
            {
                return(false);
            }
            titleTextBox.Text  = _typeBook.GetAllBookTypes()[_index].Title;
            numberTextBox.Text = _typeBook.GetAllBookTypes()[_index].NumPages;
            genreCombo.Text    = _typeBook.GetAllBookTypes()[_index].Genre.Name;
            authorCombo.Text   = _typeBook.GetAllBookTypes()[_index].AuthorInfo.AuthorPerson.Name + " " +
                                 _typeBook.GetAllBookTypes()[_index].AuthorInfo.AuthorPerson.Surname;
            publisherCombo.Text = _typeBook.GetAllBookTypes()[_index].Publisher.Name;
            copiesTextBox.Text  = _typeBook.GetAllBookTypes()[_index].PhysicalBooks
                                  .Count(bk => bk.BookInfo.TypeBookId == _typeBook.GetAllBookTypes()[_index].TypeBookId).ToString();
            return(true);
        }
        //displays the table
        public IActionResult Table()
        {
            var genres = _genreRepo.GetAllGenres();

            return(View("GenreTable", genres));
        }
Exemple #8
0
        public List <GenreListViewModel> GetAllGenres()
        {
            var genres = _genreRepo.GetAllGenres();

            return(genres);
        }