コード例 #1
0
        public SettingModel GetSetting(string key)
        {
            SettingModel model = null;

            try
            {
                IDataParameter[] parameters = new SqlParameter[] {
                    new SqlParameter("@Key", key)
                };
                model = ExecuteQuery("usp_GetSetting", parameters).To <SettingModel>().FirstOrDefault();
            }
            catch (Exception ex)
            {
                CoreLogger.Instance.Error(ex);
            }
            if (model == null)
            {
                model = new SettingModel()
                {
                    Key   = key,
                    Value = string.Empty
                };
            }
            return(model);
        }
コード例 #2
0
        public int SaveSettingModel(SettingModel model)
        {
            int rs = 0;

            try
            {
                IDataParameter[] parameters = new SqlParameter[] {
                    new SqlParameter("@Key", model.Key),
                    new SqlParameter("@Value", model.Value)
                };
                rs = ExecuteNonQuery("usp_AddSetting", parameters);
            }
            catch (Exception ex)
            {
                rs = -1;
                CoreLogger.Instance.Error(ex);
            }
            return(rs);
        }