예제 #1
0
        private static void AddWatchlistEntree()
        {
            Console.WriteLine("Please add a film to your watchlist.");
            WatchlistEntree watchlistEntree = new WatchlistEntree
            {
                Title = Console.ReadLine(),
                Date  = DateTime.Now
            };
            List <WatchlistEntree> entrees = new List <WatchlistEntree>
            {
                watchlistEntree
            };

            SqliteDataAccess.SaveWatchlist(user, entrees);
            watchlist = SqliteDataAccess.LoadWatchlist(user);
        }
예제 #2
0
        /// <summary>
        /// Reads the watchlist file and returns the users watchlist.
        /// </summary>
        public static List <WatchlistEntree> ReadWatchlist()
        {
            List <WatchlistEntree> watchlist = new List <WatchlistEntree>();

            using (StreamReader sw = File.OpenText(watchlistPath))
            {
                while (!sw.EndOfStream)
                {
                    WatchlistEntree entree = new WatchlistEntree
                    {
                        Title = sw.ReadLine()
                    };
                    watchlist.Insert(0, entree);
                }
            }
            return(watchlist);
        }
예제 #3
0
        override public string ToString()
        {
            string output = "";

            if (entrees.Count > 0)
            {
                entrees.Sort((x, y) => y.Date.CompareTo(x.Date));
                WatchlistEntree lastEntree = entrees.Last();
                foreach (WatchlistEntree entree in entrees)
                {
                    output += entree.Title;
                    if (entree != lastEntree)
                    {
                        output += ", ";
                    }
                }
            }
            return(output);
        }
예제 #4
0
        public string RecentEntreesToString()
        {
            string output = "";

            if (entrees.Count > 0)
            {
                entrees.Sort((x, y) => y.Date.CompareTo(x.Date));
                List <WatchlistEntree> recentEntrees = entrees.GetRange(0, Math.Min(RecentEntreesCount, entrees.Count));
                WatchlistEntree        lastEntree    = recentEntrees.Last();
                foreach (WatchlistEntree entree in recentEntrees)
                {
                    output += entree.Title;
                    if (entree != lastEntree)
                    {
                        output += ", ";
                    }
                }
            }
            return(output);
        }