public static bool UpdateChallenge(Challenge challenge)
{
try
{
using (SqlConnection connection = ConnectionManager.GetConnection())
{
var data = new ActivEarthDataProvidersDataContext(connection);
ChallengeDataProvider dbChallenge =
(from c in data.ChallengeDataProviders where c.id == challenge.ID select c).FirstOrDefault();
if (dbChallenge != null)
{
dbChallenge.name = challenge.Name;
dbChallenge.description = challenge.Description;
dbChallenge.reward = challenge.Reward;
dbChallenge.requirement = challenge.Requirement;
dbChallenge.persistent = challenge.IsPersistent;
dbChallenge.end_time = challenge.EndTime;
dbChallenge.duration_days = challenge.Duration.Days;
dbChallenge.statistic = (byte)challenge.StatisticBinding;
dbChallenge.active = challenge.IsActive;
dbChallenge.image_path = challenge.ImagePath;
data.SubmitChanges();
return true;
}
else
{
return false;
}
}
}
catch (Exception)
{
return false;
}
}