Exemplo n.º 1
0
        public static void Update(ForumThread obj)
        {
            if (obj == null)
                throw new Exception("Object is null");

            ForumThreadDataMapper objCaller = new ForumThreadDataMapper();

            objCaller.Update(obj);
        }
Exemplo n.º 2
0
        public static int Add(ForumThread obj)
        {
            if (obj == null)
                throw new Exception("Object is null");

            ForumThreadDataMapper objCaller = new ForumThreadDataMapper();

            return objCaller.Add(obj);
        }
Exemplo n.º 3
0
        public void PopulateForumThread(SqlDataReader _dtr, ForumThread obj)
        {
            int columnIndex = 0;
            columnIndex = _dtr.GetOrdinal(ForumThreadDataMapper.CN_FORUM_THREAD_ID);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.ID = _dtr.GetInt32((columnIndex));
            }

            columnIndex = _dtr.GetOrdinal(ForumThreadDataMapper.CN_FORUM_THREAD_CREATED_BY);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.CreatedBy = _dtr.GetInt32((columnIndex));
            }

            #region GetDateTime
            int TotalDays = 0, TotalSeconds = 0;

            columnIndex = _dtr.GetOrdinal(ForumThreadDataMapper.CN_FORUM_THREAD_CREATION_TOT_DAY);
            if (!_dtr.IsDBNull(columnIndex))
            {
                TotalDays = _dtr.GetInt32((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(ForumThreadDataMapper.CN_FORUM_THREAD_CREATION_TOT_SECOND);
            if (!_dtr.IsDBNull(columnIndex))
            {
                TotalSeconds = _dtr.GetInt32((columnIndex));
            }
            obj.CreationDate = Helper.HelperMethods.ConvertToDateTime(TotalDays, TotalSeconds);
            #endregion

            columnIndex = _dtr.GetOrdinal(ForumThreadDataMapper.CN_FORUM_THREAD_DETAILS_HTML);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.DetailsHtml = _dtr.GetString((columnIndex));
            }

            columnIndex = _dtr.GetOrdinal(ForumThreadDataMapper.CN_FORUM_THREAD_DETAILS_TEXT);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.DetailsText = _dtr.GetString((columnIndex));
            }

            columnIndex = _dtr.GetOrdinal(ForumThreadDataMapper.CN_FORUM_THREAD_FORUM_ID);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.ForumID = _dtr.GetInt32((columnIndex));
            }

            columnIndex = _dtr.GetOrdinal(ForumThreadDataMapper.CN_FORUM_THREAD_STATUS);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.Status = (RootEnums.ForumThreadStatus)_dtr.GetInt32((columnIndex));
            }

            columnIndex = _dtr.GetOrdinal(ForumThreadDataMapper.CN_FORUM_THREAD_IS_DELETED);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.IsDeleted = _dtr.GetBoolean((columnIndex));
            }

            columnIndex = _dtr.GetOrdinal(ForumThreadDataMapper.CN_FORUM_THREAD_LAST_POST_ID);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.LastPostID = _dtr.GetInt32((columnIndex));
            }

            columnIndex = _dtr.GetOrdinal(ForumThreadDataMapper.CN_FORUM_THREAD_NAME);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.Name = _dtr.GetString((columnIndex));
            }

            columnIndex = _dtr.GetOrdinal(ForumThreadDataMapper.CN_FORUM_THREAD_NUMBER_VIEWS);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.NumberThreadViews = _dtr.GetInt32((columnIndex));
            }

            columnIndex = _dtr.GetOrdinal(ForumThreadDataMapper.CN_FORUM_THREAD_TOTAL_POSTS);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.TotalPosts = _dtr.GetInt32((columnIndex));
            }
        }
Exemplo n.º 4
0
 private void GetEntityFromReader(SqlDataReader _dtr, ForumThread obj)
 {
     PopulateForumThread(_dtr, obj);
     PopulateForumUserSummary(_dtr, obj.UserSummary);
 }
Exemplo n.º 5
0
        public int Add(ForumThread obj)
        {
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = SP_ADD_FORUM_THREAD;

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

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

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

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

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

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

            parameter = new SqlParameter(PN_FORUM_THREAD_DETAILS_HTML, System.Data.SqlDbType.NText);
            parameter.Value = obj.DetailsHtml;
            parameter.Direction = System.Data.ParameterDirection.Input;
            _command.Parameters.Add(parameter);

            parameter = new SqlParameter(PN_FORUM_THREAD_DETAILS_TEXT, System.Data.SqlDbType.NText);
            parameter.Value = obj.DetailsText;
            parameter.Direction = System.Data.ParameterDirection.Input;
            _command.Parameters.Add(parameter);

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

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

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

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

            parameter = new SqlParameter(PN_FORUM_THREAD_TOTAL_POSTS, System.Data.SqlDbType.Int);
            parameter.Value = obj.TotalPosts;
            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_THREAD_ID].Value);
            return obj.ID;
        }
Exemplo n.º 6
0
 public ForumThread GetForumThread(SqlDataReader _dtr, List<ForumThread> colobj)
 {
     ForumThread obj = colobj.Where(t => t.ID == Convert.ToInt32(_dtr[CN_FORUM_THREAD_ID].ToString())).FirstOrDefault();
     if (null == obj)
     {
         obj = new ForumThread();
         colobj.Add(obj);
     }
     return obj;
 }
Exemplo n.º 7
0
        public ForumThread GetByPublishedID(int ID, Enums.RootEnums.ForumThreadStatus ForumThreadStatus)
        {
            ForumThread obj = null;
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = SP_GET_PUBLISHED_FORUM_THREAD_BY_ID;

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

            parameterID = new SqlParameter(PN_FORUM_THREAD_STATUS, SqlDbType.Int);
            parameterID.Value = (int)ForumThreadStatus;
            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 ForumThread();
                            GetEntityFromReader(_dtreader, obj);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                _dtreader.Close();
                _connection.Close();
            }

            return obj;
        }