Exemple #1
0
        public static DateTime GetLatestModifedEntryDateTime(IBlogDataService dataService, EntryCollection entries)
        {
            // Check to see if we should send a HTTP 304 letting the RSS client
            // know that they have the latest version of the feed
            DateTime latest = DateTime.MinValue;

            // need to check to see if the last entry value doesn't exist
            // if it doesn't loop through posts to get the latest date
            if (dataService.GetLastEntryUpdate() == DateTime.MinValue)
            {
                foreach (Entry entry in entries)
                {
                    DateTime created = entry.ModifiedLocalTime;
                    if (created > latest) latest = created;
                }
            }
            else
            {
                latest = dataService.GetLastEntryUpdate().ToLocalTime();
            }

            // we need to check to see if a comment entry has occured
            // after the last entry update. If it has don't return 304
            DateTime latestComment = dataService.GetLastCommentUpdate();
            if ( ( latestComment != DateTime.MinValue ) && ( latest < latestComment.ToLocalTime() ) )
                latest = latestComment.ToLocalTime();

            return new DateTime(latest.Year, latest.Month, latest.Day, latest.Hour, latest.Minute, latest.Second);
        }