ActivEarth.DAO.BadgeDAO.UpdateBadge C# (CSharp) Метод

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

Updates an existing Badge in the DB.
public static UpdateBadge ( Badge badge ) : bool
badge ActivEarth.Objects.Competition.Badges.Badge Badge whose record needs updating.
Результат bool
        public static bool UpdateBadge(Badge badge)
        {
            try
            {
                using (SqlConnection connection = ConnectionManager.GetConnection())
                {
                    var data = new ActivEarthDataProvidersDataContext(connection);
                    BadgeDataProvider dbBadge =
                        (from c in data.BadgeDataProviders where c.id == badge.ID select c).FirstOrDefault();
                    if (dbBadge != null)
                    {
                        dbBadge.user_id = badge.UserID;
                        dbBadge.badge_level = (byte)badge.Level;
                        dbBadge.progress = (byte)badge.Progress;
                        dbBadge.statistic = (byte)badge.StatisticBinding;

                        data.SubmitChanges();
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
            }
            catch (Exception)
            {
                return false;
            }
        }