/// <summary> /// Writes the Book Title to Authors file. /// </summary> /// <param name="filePath">The file path.</param> /// <param name="title">The Title to write.</param> /// <returns></returns> public bool WriteBookTitleToAuthorsFile(string filePath, string title) { if (!_validate.ValidateStringIsNotNull(title)) { return(false); } if (!_validate.ValidateStringHasLength(title)) { return(false); } if (!_validate.ValidateStringIsNotNull(filePath)) { return(false); } if (!_validate.ValidateStringHasLength(filePath)) { return(false); } if (!_validate.ValidateFileExists(filePath, true)) { return(false); } using (var writer = new StreamWriter(filePath, true)) { writer.WriteLine(title); } return(true); }
/// <summary> /// add a dash to authors name so first middle and last name can be identified /// by the program. /// </summary> /// <param name="author">The Author<see cref="string" />.</param> /// <returns>The <see cref="string" />.</returns> private string AddDashToAuthorName(string author) { this._msgBox.NameOfMethod = MethodBase.GetCurrentMethod().Name; var validate = new ValidationClass(); if (!validate.ValidateStringIsNotNull(author)) { return(string.Empty); } if (!validate.ValidateStringHasLength(author)) { return(string.Empty); } var authorName = string.Empty; foreach (var letter in author) { authorName = string.Concat(authorName, char.IsWhiteSpace(letter) ? "-" : letter.ToString()); } return(authorName); }