Beispiel #1
0
        public bool Validate()
        {
            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;
            }

            bool validUserName;

            using (UserData userData = new UserData())
            {
                validUserName = userData.GetUserByUserName(User.UserName) != null;
            }

            if (!validGenre ||
                !validType ||
                !validAuthorId ||
                !validUserName ||
                String.IsNullOrEmpty(Title) ||
                Year < 0 ||
                String.IsNullOrEmpty(Isbn))
            {
                return(false);
            }
            return(true);
        }
Beispiel #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);
        }