상속: INotifyPropertyChanging, INotifyPropertyChanged
예제 #1
0
        /// <summary>
        /// Saves a user statistic as a new entry in the DB.
        /// </summary>
        /// <param name="userId">User to create stat for.</param>
        /// <param name="statType">Statistic type to create.</param>
        /// <param name="val">Value of the statistic.</param>
        /// <returns>ID of the created statistic on success, 0 on failure.</returns>
        public static int CreateNewStatisticForUser(int userId, Statistic statType, float val)
        {
            try
            {
                int id;

                using (SqlConnection connection = ConnectionManager.GetConnection())
                {
                    var data = new ActivEarthDataProvidersDataContext(connection);
                    var statisticData = new UserStatisticDataProvider
                    {
                        user_id = userId,
                        value = val,
                        statistic_type = (byte)statType
                    };

                    data.UserStatisticDataProviders.InsertOnSubmit(statisticData);
                    data.SubmitChanges();

                    id = statisticData.id;
                }

                return id;
            }
            catch (Exception)
            {
                return 0;
            }
        }
		private void detach_UserStatisticDataProviders(UserStatisticDataProvider entity)
		{
			this.SendPropertyChanging();
			entity.UserDataProvider = null;
		}
 partial void DeleteUserStatisticDataProvider(UserStatisticDataProvider instance);
 partial void UpdateUserStatisticDataProvider(UserStatisticDataProvider instance);
 partial void InsertUserStatisticDataProvider(UserStatisticDataProvider instance);