Example #1
0
        public static void ClearCache()
        {
            NextLaunch = new LaunchData();
            CachedRockets = new List<CacheRocket>();
            CachedLaunches = new LaunchRangeList
            {
                CacheTimeOut = DateTime.Now.AddDays(-1),
                LaunchPairs = new List<LaunchData>()

            };
            CachedCacheNewsFeed = new CacheNews
            {
                NewsFeeds = new List<NewsFeed>(),
                CacheTimeOut = DateTime.Now
            };
            TrackedAgencies = new List<TrackedAgency>();
        }
Example #2
0
        public static async Task<List<LaunchData>> TryGetUpcomingLaunches()
        {
            if (DateTime.Now < CachedLaunches?.CacheTimeOut)
                return CachedLaunches.LaunchPairs.ToList();

            var upcomingLaunches =
                await ApiManager.LaunchesByDate(
                    DateTime.Now.FirstDayOfMonth(), 
                    DateTime.Now.LastDayOfMonth().AddDays(14)
                    );

            var launchPairs = upcomingLaunches.Select(upcomingLaunch => new LaunchData
            {
                Launch = upcomingLaunch,
                Mission = null,
                Forecast = null,
                CacheTimeOut = upcomingLaunch.Net.AddHours(1)
            }).ToList();

            TrackingManager.UpdateTrackedLaunches(launchPairs);

            CachedLaunches = new LaunchRangeList
            {
                LaunchPairs = launchPairs,
                CacheTimeOut = DateTime.Now.AddDays(7)
            };

            return launchPairs;
        }