Example #1
0
 public string ValidateRelease()
 {
     using (BookData bookData = new BookData())
     {
         Book book = bookData.GetBookById(BookId);
         if (book == null)
         {
             return("Book with this id does not exist");
         }
         else if (!book.Reserved)
         {
             return("Book not reserved");
         }
         else
         {
             return("");
         }
     }
 }
Example #2
0
        public bool ValidateEdit()
        {
            bool validBookId;

            using (BookData genreData = new BookData())
            {
                validBookId = genreData.GetBookById(BookId) != null;
            }

            bool validGenre;

            using (GenreData genreData = new GenreData())
            {
                validGenre = genreData.GetGenreIdByName(Genre) >= 0;
            }

            bool validType;

            using (TypeData typeData = new TypeData())
            {
                validType = typeData.GetTypeIdByName(Type) >= 0;
            }

            bool validAuthorId;

            using (AuthorData authorData = new AuthorData())
            {
                validAuthorId = authorData.GetAuthorById(Author.AuthorId) != null;
            }

            if (!validGenre ||
                !validType ||
                !validAuthorId ||
                !validBookId ||
                String.IsNullOrEmpty(Title) ||
                Year < 0 ||
                String.IsNullOrEmpty(Isbn))
            {
                return(false);
            }
            return(true);
        }