コード例 #1
0
        public static MemberBlogSettings GetMemberBlogSettingsByMemberID(int MemberID)
        {
            Database db = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("AG_GetMemberBlogSettingsByMemberID");
            db.AddInParameter(dbCommand, "MemberID", DbType.Int32, MemberID);

            List<MemberBlogSettings> arr = null;

            try
            {
                IDataReader dr = db.ExecuteReader(dbCommand);
                // Call the PopulateObject method passing the datareader to return the object array
                arr = Next2Friends.Data.MemberBlogSettings.PopulateObject(dr);
                dr.Close();
            }
            catch(Exception ex)
            {

                throw ex;
            }


            if (arr.Count == 0)
            {
                MemberBlogSettings memberBlogSettings = new MemberBlogSettings();
                memberBlogSettings.MemberID = MemberID;
                return memberBlogSettings;
            }
            else
            {
                return arr[0];
            }
        }
コード例 #2
0
        /// <summary>
        /// Takes an prepopulated IDataReader and creates an array of MemberBlogSettingss
        /// </summary>
        public static List<MemberBlogSettings> PopulateObject(IDataReader dr)
        {
            ColumnFieldList list = new ColumnFieldList(dr);

            List<MemberBlogSettings> arr = new List<MemberBlogSettings>();

            MemberBlogSettings obj;

            while (dr.Read())
            {
                obj = new MemberBlogSettings();
                if (list.IsColumnPresent("MemberBlogSettingsID")) { obj._memberBlogSettingsID = (int)dr["MemberBlogSettingsID"]; }
                if (list.IsColumnPresent("MemberID")) { obj._memberID = (int)dr["MemberID"]; }
                if (list.IsColumnPresent("BloggerUserName")) { obj._bloggerUserName = (string)dr["BloggerUserName"]; }
                if (list.IsColumnPresent("BloggerPassword")) { obj._bloggerPassword = (string)dr["BloggerPassword"]; }
                if (list.IsColumnPresent("BloggerAutoSubmit")) { obj._bloggerAutoSubmit = (bool)dr["BloggerAutoSubmit"]; }
                if (list.IsColumnPresent("LiveJournalUserName")) { obj._liveJournalUserName = (string)dr["LiveJournalUserName"]; }
                if (list.IsColumnPresent("LiveJournalPassword")) { obj._liveJournalPassword = (string)dr["LiveJournalPassword"]; }
                if (list.IsColumnPresent("LiveJournalAutoSubmit")) { obj._liveJournalAutoSubmit = (bool)dr["LiveJournalAutoSubmit"]; }
                if (list.IsColumnPresent("WordPressUserName")) { obj._wordPressUserName = (string)dr["WordPressUserName"]; }
                if (list.IsColumnPresent("WordPressPassword")) { obj._wordPressPassword = (string)dr["WordPressPassword"]; }
                if (list.IsColumnPresent("WordPressURL")) { obj._wordPressURL = (string)dr["WordPressURL"]; }
                if (list.IsColumnPresent("WordPressAutoSubmit")) { obj._wordPressAutoSubmit = (bool)dr["WordPressAutoSubmit"]; }

                arr.Add(obj);
            }

            dr.Close();

            return arr;
        }