ActivEarth.DAO.ChallengeDAO.CreateInitializationEntry C# (CSharp) Method

CreateInitializationEntry() public static method

Creates a new user initialization entry for a challenge.
public static CreateInitializationEntry ( int challengeId, int userId, float value ) : bool
challengeId int ID of the challenge the user is participating in.
userId int ID of the user being initialized.
value float Current value of the relevant statistic for the challenge.
return bool
        public static bool CreateInitializationEntry(int challengeId, int userId, float value)
        {
            try
            {
                using (SqlConnection connection = ConnectionManager.GetConnection())
                {
                    var data = new ActivEarthDataProvidersDataContext(connection);
                    var challengeData = new ChallengeInitializationDataProvider
                    {
                        challenge_id = challengeId,
                        user_id = userId,
                        value = value
                    };
                    data.ChallengeInitializationDataProviders.InsertOnSubmit(challengeData);
                    data.SubmitChanges();
                    return (challengeData.id > 0);
                }
            }
            catch (Exception)
            {
                return false;
            }
        }