/// <summary> /// Validates a periodical using the passed parameters and returns an error message if invalid /// </summary> /// <param name="price">The price of the periodical</param> /// <param name="description">The title of the periodical</param> /// <param name="companyName">The company name of the periodical</param> /// <param name="publishDate">The publish date of the periodical</param> /// <returns>An error message if invalid</returns> public static string Validate(decimal price, string description, string companyName, DateTime publishDate) { string errorMessage = DBItem.Validate(price, description); if (String.IsNullOrEmpty(companyName)) { errorMessage += "Company name cannot be empty." + Environment.NewLine; } if (publishDate > DateTime.Now) { errorMessage += "Publish date cannot be greater than the current date." + Environment.NewLine; } return(errorMessage); }
/// <summary> /// Validates a map using the passed arguments and returns an error message if invalid /// </summary> /// <param name="price">The price to validate</param> /// <param name="description">The description/location of the map to validate</param> /// <param name="year">The year to validate</param> /// <param name="publisher">The publisher to validate</param> /// <returns>An error message if invalid</returns> public static string Validate(decimal price, string description, int year, string publisher) { string errorMessage = DBItem.Validate(price, description); if (year > DateTime.Now.Year) { errorMessage += "Year cannot be greater than the current year." + Environment.NewLine; } if (String.IsNullOrEmpty(publisher)) { errorMessage += "Publisher cannot be empty." + Environment.NewLine; } return(errorMessage); }
/// <summary> /// Validates a book with the passed arguments and returns an error message if invalid /// </summary> /// <param name="price">The price of the book</param> /// <param name="description">The title/description of the book</param> /// <param name="authorFirst">The first name of the author of the book</param> /// <param name="authorLast">The last name of the author of the book</param> /// <param name="publisher">The publisher of the book</param> /// <param name="publishDate">The date the book was published</param> /// <returns>An error message if invalid</returns> public static string Validate(decimal price, string description, string authorFirst, string authorLast, string publisher, DateTime publishDate) { string errorMessage = DBItem.Validate(price, description); if (String.IsNullOrEmpty(authorFirst)) { errorMessage += "Author first name cannot be empty." + Environment.NewLine; } if (String.IsNullOrEmpty(authorLast)) { errorMessage += "Author last name cannot be empty." + Environment.NewLine; } if (String.IsNullOrEmpty(publisher)) { errorMessage += "Publisher cannot be empty." + Environment.NewLine; } if (publishDate > DateTime.Now) { errorMessage += "Publish date cannot be greater than the current date." + Environment.NewLine; } return(errorMessage); }