示例#1
0
        public static void Update(ForumUser obj)
        {
            if (obj == null)
                throw new Exception("Object is null");

            ForumUserDataMapper objCaller = new ForumUserDataMapper();
            objCaller.Update(obj);
        }
示例#2
0
        public static int Add(ForumUser obj)
        {
            if (obj == null)
                throw new Exception("Object is null");

            ForumUserDataMapper objCaller = new ForumUserDataMapper();
            return objCaller.Add(obj);
        }
示例#3
0
        public void PopulateForumUser(SqlDataReader _dtr, ForumUser obj)
        {
            int columnIndex = 0;
            columnIndex = _dtr.GetOrdinal(ForumUserDataMapper.CN_FORUM_USER_ID);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.ID = _dtr.GetInt32((columnIndex));
            }

            int TotalDays = 0, TotalSeconds = 0;
            columnIndex = _dtr.GetOrdinal(ForumUserDataMapper.CN_FORUM_USER_BANNED_TOT_DAY);
            if (!_dtr.IsDBNull(columnIndex))
            {
                TotalDays = _dtr.GetInt32((columnIndex));
            }

            columnIndex = _dtr.GetOrdinal(ForumUserDataMapper.CN_FORUM_USER_BANNED_TOT_SECOND);
            if (!_dtr.IsDBNull(columnIndex))
            {
                TotalSeconds = _dtr.GetInt32((columnIndex));
            }
            obj.BannedDate = Helper.HelperMethods.ConvertToDateTime(TotalDays, TotalSeconds);

            columnIndex = _dtr.GetOrdinal(ForumUserDataMapper.CN_FORUM_USER_BIRTH_TOT_DAY);
            if (!_dtr.IsDBNull(columnIndex))
            {
                TotalDays = _dtr.GetInt32((columnIndex));
            }

            columnIndex = _dtr.GetOrdinal(ForumUserDataMapper.CN_FORUM_USER_BIRTH_TOT_SECOND);
            if (!_dtr.IsDBNull(columnIndex))
            {
                TotalSeconds = _dtr.GetInt32((columnIndex));
            }
            obj.BirthDate = Helper.HelperMethods.ConvertToDateTime(TotalDays, TotalSeconds);

            columnIndex = _dtr.GetOrdinal(ForumUserDataMapper.CN_FORUM_USER_FORUM_USER_TYPE);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.ForumUserType = (RootEnums.ForumUserType)(_dtr.GetInt32((columnIndex)));
            }

            columnIndex = _dtr.GetOrdinal(ForumUserDataMapper.CN_FORUM_USER_IMAGE);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.Image = _dtr.GetString((columnIndex));
            }

            columnIndex = _dtr.GetOrdinal(ForumUserDataMapper.CN_FORUM_USER_IS_BANNED);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.IsBanned = _dtr.GetBoolean((columnIndex));
            }

            columnIndex = _dtr.GetOrdinal(ForumUserDataMapper.CN_FORUM_USER_IS_TRUSTED);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.IsTrusted = _dtr.GetBoolean((columnIndex));
            }

            columnIndex = _dtr.GetOrdinal(ForumUserDataMapper.CN_FORUM_USER_JOIN_TOT_DAY);
            if (!_dtr.IsDBNull(columnIndex))
            {
                TotalDays = _dtr.GetInt32((columnIndex));
            }

            columnIndex = _dtr.GetOrdinal(ForumUserDataMapper.CN_FORUM_USER_JOIN_TOT_SECOND);
            if (!_dtr.IsDBNull(columnIndex))
            {
                TotalSeconds = _dtr.GetInt32((columnIndex));
            }
            obj.JoinDate = Helper.HelperMethods.ConvertToDateTime(TotalDays, TotalSeconds);

            columnIndex = _dtr.GetOrdinal(ForumUserDataMapper.CN_FORUM_USER_POSTS_PER_PAGE);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.PostsPerPage = _dtr.GetInt32((columnIndex));
            }

            columnIndex = _dtr.GetOrdinal(ForumUserDataMapper.CN_FORUM_USER_ROLE_ID);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.RoleID = _dtr.GetInt32((columnIndex));
            }

            columnIndex = _dtr.GetOrdinal(ForumUserDataMapper.CN_FORUM_USER_SIGNATURE);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.Signature = _dtr.GetString((columnIndex));
            }

            columnIndex = _dtr.GetOrdinal(ForumUserDataMapper.CN_FORUM_USER_THREADS_PER_PAGE);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.ThreadsPerPage = _dtr.GetInt32((columnIndex));
            }

            columnIndex = _dtr.GetOrdinal(ForumUserDataMapper.CN_FORUM_USER_USER_ID);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.UserID = _dtr.GetInt32((columnIndex));
            }

            columnIndex = _dtr.GetOrdinal(ForumUserDataMapper.CN_FORUM_USER_USER_RATE_VALUE);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.UserRateValue = _dtr.GetInt32((columnIndex));
            }

            columnIndex = _dtr.GetOrdinal(ForumUserDataMapper.CN_FORUM_USER_NAME);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.UserName = _dtr.GetString((columnIndex));
            }

            columnIndex = _dtr.GetOrdinal(ForumUserDataMapper.CN_FORUM_USER_IS_DELETED);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.IsDeleted = _dtr.GetBoolean((columnIndex));
            }
        }
示例#4
0
        public int Add(ForumUser obj)
        {
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = SP_ADD_FORUM;

            #region [Parameters]
            SqlParameter parameter = new SqlParameter(PN_FORUM_USER_ID, System.Data.SqlDbType.Int);
            parameter.Direction = System.Data.ParameterDirection.Output;
            _command.Parameters.Add(parameter);

            parameter = new SqlParameter(PN_FORUM_USER_BANNED_TOT_DAY, System.Data.SqlDbType.Int);
            parameter.Value = Helper.HelperMethods.GetTotalDays(obj.BannedDate);
            parameter.Direction = System.Data.ParameterDirection.Input;
            _command.Parameters.Add(parameter);

            parameter = new SqlParameter(PN_FORUM_USER_BANNED_TOT_SECOND, System.Data.SqlDbType.Int);
            parameter.Value = Helper.HelperMethods.GetTotalSeconds(obj.BannedDate);
            parameter.Direction = System.Data.ParameterDirection.Input;
            _command.Parameters.Add(parameter);

            parameter = new SqlParameter(PN_FORUM_USER_BIRTH_TOT_DAY, System.Data.SqlDbType.Int);
            parameter.Value = Helper.HelperMethods.GetTotalDays(obj.BirthDate);
            parameter.Direction = System.Data.ParameterDirection.Input;
            _command.Parameters.Add(parameter);

            parameter = new SqlParameter(PN_FORUM_USER_BIRTH_TOT_SECOND, System.Data.SqlDbType.Int);
            parameter.Value = Helper.HelperMethods.GetTotalSeconds(obj.BirthDate);
            parameter.Direction = System.Data.ParameterDirection.Input;
            _command.Parameters.Add(parameter);

            parameter = new SqlParameter(PN_FORUM_USER_FORUM_USER_TYPE, System.Data.SqlDbType.Int);
            parameter.Value = (int)obj.ForumUserType;
            parameter.Direction = System.Data.ParameterDirection.Input;
            _command.Parameters.Add(parameter);

            parameter = new SqlParameter(PN_FORUM_USER_IMAGE, System.Data.SqlDbType.NVarChar);
            parameter.Value = obj.Image;
            parameter.Direction = System.Data.ParameterDirection.Input;
            _command.Parameters.Add(parameter);

            parameter = new SqlParameter(PN_FORUM_USER_IS_BANNED, System.Data.SqlDbType.Bit);
            parameter.Value = obj.IsBanned;
            parameter.Direction = System.Data.ParameterDirection.Input;
            _command.Parameters.Add(parameter);

            parameter = new SqlParameter(PN_FORUM_USER_IS_TRUSTED, System.Data.SqlDbType.Bit);
            parameter.Value = obj.IsTrusted;
            parameter.Direction = System.Data.ParameterDirection.Input;
            _command.Parameters.Add(parameter);

            parameter = new SqlParameter(PN_FORUM_USER_JOIN_TOT_DAY, System.Data.SqlDbType.Int);
            parameter.Value = Helper.HelperMethods.GetTotalDays(obj.JoinDate);
            parameter.Direction = System.Data.ParameterDirection.Input;
            _command.Parameters.Add(parameter);

            parameter = new SqlParameter(PN_FORUM_USER_JOIN_TOT_SECOND, System.Data.SqlDbType.Int);
            parameter.Value = Helper.HelperMethods.GetTotalSeconds(obj.JoinDate);
            parameter.Direction = System.Data.ParameterDirection.Input;
            _command.Parameters.Add(parameter);

            parameter = new SqlParameter(PN_FORUM_USER_NAME, System.Data.SqlDbType.NVarChar);
            parameter.Value = obj.UserName;
            parameter.Direction = System.Data.ParameterDirection.Input;
            _command.Parameters.Add(parameter);

            parameter = new SqlParameter(PN_FORUM_USER_POSTS_PER_PAGE, System.Data.SqlDbType.Int);
            parameter.Value = obj.PostsPerPage;
            parameter.Direction = System.Data.ParameterDirection.Input;
            _command.Parameters.Add(parameter);

            parameter = new SqlParameter(PN_FORUM_USER_ROLE_ID, System.Data.SqlDbType.Int);
            parameter.Value = obj.RoleID;
            parameter.Direction = System.Data.ParameterDirection.Input;
            _command.Parameters.Add(parameter);

            parameter = new SqlParameter(PN_FORUM_USER_SIGNATURE, System.Data.SqlDbType.NVarChar);
            parameter.Value = obj.Signature;
            parameter.Direction = System.Data.ParameterDirection.Input;
            _command.Parameters.Add(parameter);

            parameter = new SqlParameter(PN_FORUM_USER_THREADS_PER_PAGE, System.Data.SqlDbType.Int);
            parameter.Value = obj.ThreadsPerPage;
            parameter.Direction = System.Data.ParameterDirection.Input;
            _command.Parameters.Add(parameter);

            parameter = new SqlParameter(PN_FORUM_USER_USER_ID, System.Data.SqlDbType.Int);
            parameter.Value = obj.UserID;
            parameter.Direction = System.Data.ParameterDirection.Input;
            _command.Parameters.Add(parameter);

            parameter = new SqlParameter(PN_FORUM_USER_USER_RATE_VALUE, System.Data.SqlDbType.Int);
            parameter.Value = obj.UserRateValue;
            parameter.Direction = System.Data.ParameterDirection.Input;
            _command.Parameters.Add(parameter);

            parameter = new SqlParameter(PN_FORUM_USER_IS_DELETED, System.Data.SqlDbType.Bit);
            parameter.Value = obj.IsDeleted;
            parameter.Direction = System.Data.ParameterDirection.Input;
            _command.Parameters.Add(parameter);
            #endregion

            _connection.Open();
            _command.ExecuteNonQuery();
            _connection.Close();
            obj.ID = Convert.ToInt32(_command.Parameters[PN_FORUM_USER_ID].Value);
            return obj.ID;
        }
示例#5
0
 private void GetEntityFromReader(SqlDataReader _dtr, ForumUser obj)
 {
     PopulateForumUser(_dtr, obj);
 }
示例#6
0
 public ForumUser GetForumUser(SqlDataReader _dtr, IList<ForumUser> colobj)
 {
     ForumUser obj = colobj.Where(t => t.ID == Convert.ToInt32(_dtr[CN_FORUM_USER_ID].ToString())).FirstOrDefault();
     if (null == obj)
     {
         obj = new ForumUser();
         colobj.Add(obj);
     }
     return obj;
 }
示例#7
0
        public ForumUser GetByUserID(int UserID)
        {
            ForumUser obj = null;
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = SP_GET_FORUM_USER_BY_USER_ID;

            #region [Parameters]
            SqlParameter parameterID = new SqlParameter(PN_FORUM_USER_USER_ID, SqlDbType.Int);
            parameterID.Value = UserID;
            parameterID.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterID);
            #endregion

            _connection.Open();
            try
            {
                using (_dtreader = _command.ExecuteReader())
                {
                    if (_dtreader != null && _dtreader.HasRows)
                    {
                        while (_dtreader.Read())
                        {
                            if (obj == null)
                                obj = new ForumUser();
                            GetEntityFromReader(_dtreader, obj);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                _dtreader.Close();
                _connection.Close();
            }

            return obj;
        }