Exemplo n.º 1
0
        /// <summary>
        /// Checks whether and of the Properties of this object contains the string passed in the argument
        /// </summary>
        /// <param name="searchToken">string used to compare with this object's fields and properties</param>
        /// <returns>Returns true if this object contains the search token, false otherwise</returns>
        public bool ContainsToken(string searchToken)
        {
            //remove white spaces
            string token = new string(searchToken.ToCharArray().Where(c => !Char.IsWhiteSpace(c)).ToArray());

            if (Title.ToLower().Contains(token))
            {
                return(true);
            }

            string authorName = Author.Person.FirstName + Author.Person.LastName;

            if (authorName.ToLower().Contains(token.ToLower()))
            {
                return(true);
            }

            if (ISBN.Contains(token))
            {
                return(true);
            }
            if (Subject.ToLower().Contains(token))
            {
                return(true);
            }

            return(false);
        }