Пример #1
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Shows all friends. </summary>
        ///
        /// <remarks>   , 16/08/2018. </remarks>
        ///
        /// <returns>   A List&lt;Friend&gt; </returns>
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        public static List <Friend> ShowAllFriends()
        {
            //create a new csv handler object
            CsvHandler getFriends = new CsvHandler();

            //get all the data from the csv and put it in the friends list
            List <Friend> friends = getFriends.ReadCsv();

            return(friends);
        }
Пример #2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Friends in month. </summary>
        ///
        /// <remarks>   , 16/08/2018. </remarks>
        ///
        /// <param name="month">    The month. </param>
        ///
        /// <returns>   A List&lt;Friend&gt; </returns>
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        public static List <Friend> FriendsInMonth(int month)
        {
            //read the csv file and put all friends into the list
            CsvHandler    readCsv = new CsvHandler();
            List <Friend> friends = new List <Friend>();

            friends = readCsv.ReadCsv();

            //search through the friends and look at the month of their birthday and return a list
            List <Friend> birthdaysInMonth = new List <Friend>();

            foreach (Friend friend in friends)
            {
                if (friend.BirthMonth == month)
                {
                    birthdaysInMonth.Add(friend);
                }
            }
            return(birthdaysInMonth);
        }
Пример #3
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Searches for the first friend. </summary>
        ///
        /// <remarks>   , 16/08/2018. </remarks>
        ///
        /// <param name="friendName">   Name of the friend. </param>
        ///
        /// <returns>   The found friend. </returns>
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        public static List <Friend> FindFriend(string friendName)
        {
            //read the csv file and put all of them into a list
            CsvHandler    readCsv = new CsvHandler();
            List <Friend> friends = new List <Friend>();

            friends = readCsv.ReadCsv();

            //search through list and return another list of friends using the search data
            List <Friend> search = new List <Friend>();

            foreach (Friend friend in friends)
            {
                //ToUpper is used so capitalization isnt an issue when searching
                if (friend.Name.ToUpper().Contains(friendName.ToUpper()))
                {
                    search.Add(friend);
                    Debug.WriteLine(friend.Name);
                }
            }
            //return the list to be displayed
            return(search);
        }