/// <summary>
        /// Gets the book list titles file path.
        /// </summary>
        /// <returns>True if path found else False.</returns>
        public bool GetBookListTitlesFilePath()
        {
            var dirFileOp = new FileClass();
            var validate  = new ValidationClass();

            var dirPath = BookListPathsProperties.PathTitlesDirectory;

            var fileName = BookListPathsProperties.NameTitlesBookListFile;

            var cls      = new CombinePathsClass();
            var filePath = cls.CombineDirectoryPathWithFileName(
                dirPath, fileName);

            var fileExists = validate.ValidateFileExists(filePath, true);

            if (!fileExists)
            {
                var dlgResult = this._msgBox.ShowQuestionMessageBox();

                // Create directory if it does not exist.
                if (dlgResult == DialogResult.Yes)
                {
                    dirFileOp.CreateNewFile(filePath);

                    if (validate.ValidateFileExists(filePath, true))
                    {
                        BookListPathsProperties.PathTitleNamesListFile = filePath;
                        return(true);
                    }
                    else
                    {
                        // return no directory created.
                        BookListPathsProperties.PathTitleNamesListFile = String.Empty;
                        return(false);
                    }
                }
                else
                {
                    // return user does not want to create the directory.
                    BookListPathsProperties.PathTitleNamesListFile = String.Empty;
                    return(false);
                }
            }
            else
            {
                BookListPathsProperties.PathTitleNamesListFile = filePath;
                return(true);
            }
        }
        /// <summary>
        ///     Gets the application data directory path.
        /// </summary>
        /// <returns>
        /// </returns>
        public bool GetAppDataDirectoryPath()
        {
            var validate = new ValidationClass();

            var cls = new FileClass();

            // Saves the AppData directory path to BookListPathsProperties.PathAppDataDirectory
            GetPathToSpecialDirectoryAppDataLocal();

            if (validate.ValidateDirectoryExists(BookListPathsProperties.PathAppDataDirectory))
            {
                return(true);
            }

            _msgBox.Msg = "Unable to find the AppData directory unable to continue.";
            _msgBox.ShowErrorMessageBox();
            return(false);
        }
示例#3
0
        /// <summary>
        ///     Add dash between authors first middle and last name. This allows the
        ///     program to tell where each name begins and ends.
        /// </summary>
        /// <param name="author">The Author<see cref="string" />.</param>
        /// <returns>Return the authors name with dashes installed.</returns>
        public string AddDashBetweenAuthorsFirstMiddleLastName(string author)
        {
            this._msgBox.NameOfMethod = MethodBase.GetCurrentMethod().Name;


            if (!this._valid.ValidateStringIsNotNull(author))
            {
                return(string.Empty);
            }
            if (!this._valid.ValidateStringHasLength(author))
            {
                return(string.Empty);
            }

            var authorName = this.AddDashToAuthorName(author.Trim());

            var clsFile = new FileClass();

            return(clsFile.AddFileExtension(authorName));
        }
示例#4
0
        /// <summary>
        ///     Searches the book title all authors.
        /// </summary>
        public void SearchBookAuthorAllTitles()
        {
            this._msgBox.NameOfMethod = MethodBase.GetCurrentMethod().Name;

            var cls1 = new FileClass();

            cls1.GetAllAuthorFilePathsContainedInAuthorDirectory();

            var coll1 = new BookDataCollection();

            coll1.ClearCollection();

            this.AuthorNamesSearchLoop();


            var coll2 = new BookTitlesCollection();

            if (coll2.GetItemsCount() < 1)
            {
                coll2.AddItem("No titles with this search criteria were found.");
            }
        }