public void Refresh(string szUser, DateTime dtStart, DateTime dtEnd, bool fIncludeBadges) { if (szUser == null) { throw new ArgumentNullException("szUser"); } if (String.IsNullOrWhiteSpace(szUser)) { throw new MyFlightbookValidationException("Invalid user"); } lblTitle.Text = String.Format(CultureInfo.CurrentCulture, Resources.Achievements.RecentAchievementsTitle, dtStart, dtEnd); RecentAchievements ra = new RecentAchievements(dtStart, dtEnd) { Username = szUser }; Collection <MilestoneItem> c = ra.Refresh(); rptRecentAchievements.DataSource = c; rptRecentAchievements.DataBind(); List <Badge> lstBadges = null; if (fIncludeBadges) { lstBadges = new Achievement(szUser).BadgesForUser(); lstBadges.RemoveAll(b => b.DateEarned.CompareTo(dtStart) < 0 || b.DateEarned.CompareTo(dtEnd) > 0); rptRecentlyearnedBadges.DataSource = BadgeSet.BadgeSetsFromBadges(lstBadges); rptRecentlyearnedBadges.DataBind(); } pnlStatsAndAchievements.Visible = (lstBadges != null && lstBadges.Count > 0) || (c != null && c.Count() > 0); }
public int Refresh(string szUser, DateTime dtStart, DateTime dtEnd, bool fIncludeBadges) { if (szUser == null) { throw new ArgumentNullException(nameof(szUser)); } if (String.IsNullOrWhiteSpace(szUser)) { throw new MyFlightbookValidationException("Invalid user"); } RecentAchievements ra = new RecentAchievements(dtStart, dtEnd) { Username = szUser, AutoDateRange = AutoDateRange }; Collection <MilestoneItem> c = ra.Refresh(); rptRecentAchievements.DataSource = c; rptRecentAchievements.DataBind(); AchievementCount = c.Count; Summary = String.Format(CultureInfo.CurrentCulture, fIncludeBadges ? Resources.Achievements.RecentAchievementsTitle : Resources.Achievements.RecentStatsTitle, ra.StartDate, ra.EndDate); List <Badge> lstBadges = null; if (fIncludeBadges) { lstBadges = new Achievement(szUser).BadgesForUser(); lstBadges.RemoveAll(b => b.DateEarned.CompareTo(dtStart) < 0 || b.DateEarned.CompareTo(dtEnd) > 0); AchievementCount += lstBadges.Count; rptRecentlyearnedBadges.DataSource = BadgeSet.BadgeSetsFromBadges(lstBadges); rptRecentlyearnedBadges.DataBind(); } pnlStatsAndAchievements.Visible = (lstBadges != null && lstBadges.Count > 0) || (c != null && c.Count > 0); if (ShowCalendar) { RefreshCalendar(ra); } return(AchievementCount); }