ActivEarth.DAO.UserStatisticDAO.UpdateUserStatistic C# (CSharp) Метод

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

Updates an existing UserStatistic in the DB.
public static UpdateUserStatistic ( UserStatistic statistic ) : bool
statistic ActivEarth.Objects.Profile.UserStatistic UserStatistic whose record needs updating.
Результат bool
        public static bool UpdateUserStatistic(UserStatistic statistic)
        {
            try
            {
                using (SqlConnection connection = ConnectionManager.GetConnection())
                {
                    var data = new ActivEarthDataProvidersDataContext(connection);
                    UserStatisticDataProvider dbStatistic =
                        (from p in data.UserStatisticDataProviders where p.id == statistic.UserStatisticID select p).FirstOrDefault();

                    if (dbStatistic != null)
                    {
                        dbStatistic.statistic_type = (byte)statistic.Statistic;
                        dbStatistic.user_id = statistic.UserID;
                        dbStatistic.value = statistic.Value;

                        data.SubmitChanges();
                    }
                    else
                    {
                        return false;
                    }
                }

                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }