ActivEarth.DAO.ChallengeDAO.GetActiveChallenges C# (CSharp) Метод

GetActiveChallenges() публичный статический Метод

Retrieves all currently active challenges.
public static GetActiveChallenges ( int userId ) : List
userId int Optional. UserID to load challenge progress from.
Результат List
        public static List<Challenge> GetActiveChallenges(int userId = 0)
        {
            List<Challenge> toReturn;

            using (SqlConnection connection = ConnectionManager.GetConnection())
            {
                var data = new ActivEarthDataProvidersDataContext(connection);
                toReturn = (from c in data.ChallengeDataProviders
                        where c.active
                        select
                            new Challenge
                            {
                                ID = c.id,
                                Name = c.name,
                                Description = c.description,
                                Reward = c.reward,
                                Requirement = (float)c.requirement,
                                IsPersistent = c.persistent,
                                EndTime = c.end_time,
                                Duration = new TimeSpan(c.duration_days, 0, 0, 0),
                                StatisticBinding = (Statistic)c.statistic,
                                IsActive = c.active,
                                ImagePath = c.image_path
                            }).ToList();

                foreach (Challenge challenge in toReturn)
                {
                    challenge.Progress = (userId > 0 ? ChallengeManager.GetProgress(challenge.ID, userId) : 0);
                    challenge.FormatString = StatisticInfoDAO.GetStatisticFormatString(challenge.StatisticBinding);
                }

                return toReturn;
            }
        }