public void PopulateComment(SqlDataReader _dtr, Comment obj) { int columnIndex = 0; columnIndex = _dtr.GetOrdinal(CommentDataMapper.CN_ID); if (!_dtr.IsDBNull(columnIndex)) { obj.ID = _dtr.GetInt32((columnIndex)); } columnIndex = _dtr.GetOrdinal(CommentDataMapper.CN_NAME); if (!_dtr.IsDBNull(columnIndex)) { obj.Name = _dtr.GetString((columnIndex)); } columnIndex = _dtr.GetOrdinal(CommentDataMapper.CN_SUBJECT); if (!_dtr.IsDBNull(columnIndex)) { obj.Subject = _dtr.GetString((columnIndex)); } columnIndex = _dtr.GetOrdinal(CommentDataMapper.CN_COMPANY); if (!_dtr.IsDBNull(columnIndex)) { obj.Company = _dtr.GetString((columnIndex)); } columnIndex = _dtr.GetOrdinal(CommentDataMapper.CN_EMAIL); if (!_dtr.IsDBNull(columnIndex)) { obj.Email = _dtr.GetString((columnIndex)); } columnIndex = _dtr.GetOrdinal(CommentDataMapper.CN_COUNTRY); if (!_dtr.IsDBNull(columnIndex)) { obj.Country = _dtr.GetString((columnIndex)); } columnIndex = _dtr.GetOrdinal(CommentDataMapper.CN_OBJECTID); if (!_dtr.IsDBNull(columnIndex)) { obj.ObjectID = _dtr.GetInt32((columnIndex)); } columnIndex = _dtr.GetOrdinal(CommentDataMapper.CN_OBJECTTYPE); if (!_dtr.IsDBNull(columnIndex)) { obj.ObjectType = (RootEnums.ObjectType)_dtr.GetInt32((columnIndex)); } columnIndex = _dtr.GetOrdinal(CommentDataMapper.CN_TYPE); if (!_dtr.IsDBNull(columnIndex)) { obj.Type = (RootEnums.CommentType)_dtr.GetInt32((columnIndex)); } columnIndex = _dtr.GetOrdinal(CommentDataMapper.CN_STATUS); if (!_dtr.IsDBNull(columnIndex)) { obj.Status = (TG.ExpressCMS.DataLayer.Enums.RootEnums.CommentStatus)_dtr.GetInt32((columnIndex)); } columnIndex = _dtr.GetOrdinal(CommentDataMapper.CN_ISDELETED); if (!_dtr.IsDBNull(columnIndex)) { obj.IsDeleted = _dtr.GetBoolean((columnIndex)); } columnIndex = _dtr.GetOrdinal(CommentDataMapper.CN_INTIALVALUE); if (!_dtr.IsDBNull(columnIndex)) { obj.IntialValue = _dtr.GetString((columnIndex)); } columnIndex = _dtr.GetOrdinal(CommentDataMapper.CN_MODIFIEDVALUE); if (!_dtr.IsDBNull(columnIndex)) { obj.ModifiedValue = _dtr.GetString((columnIndex)); } columnIndex = _dtr.GetOrdinal(CommentDataMapper.CN_IPADDRESS); if (!_dtr.IsDBNull(columnIndex)) { obj.IPAddress = _dtr.GetString((columnIndex)); } }
public Comment GetComment(SqlDataReader _dtr, IList<Comment> colobj) { Comment obj = colobj.Where(t => t.ID == Convert.ToInt32(_dtr[CN_ID].ToString())).SingleOrDefault(); if (null == obj) { obj = new Comment(); colobj.Add(obj); } return obj; }
public int Add(Comment obj) { _connection.ConnectionString = _ConnectionString; _command.Connection = _connection; _command.CommandType = CommandType.StoredProcedure; _command.CommandText = INSERTComment; #region [Parameters] SqlParameter parameterID = new SqlParameter(PN_ID, SqlDbType.Int); parameterID.Value = obj.ID; parameterID.Direction = ParameterDirection.Output; _command.Parameters.Add(parameterID); SqlParameter parameterName = new SqlParameter(PN_NAME, SqlDbType.NVarChar); parameterName.Value = obj.Name; parameterName.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterName); SqlParameter parameterSubject = new SqlParameter(PN_SUBJECT, SqlDbType.NVarChar); parameterSubject.Value = obj.Subject; parameterSubject.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterSubject); SqlParameter parameterCompany = new SqlParameter(PN_COMPANY, SqlDbType.NVarChar); parameterCompany.Value = obj.Company; parameterCompany.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterCompany); SqlParameter parameterEmail = new SqlParameter(PN_EMAIL, SqlDbType.NVarChar); parameterEmail.Value = obj.Email; parameterEmail.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterEmail); SqlParameter parameterCountry = new SqlParameter(PN_COUNTRY, SqlDbType.NVarChar); parameterCountry.Value = obj.Country; parameterCountry.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterCountry); SqlParameter parameterObjectID = new SqlParameter(PN_OBJECTID, SqlDbType.Int); parameterObjectID.Value = obj.ObjectID; parameterObjectID.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterObjectID); SqlParameter parameterObjectType = new SqlParameter(PN_OBJECTTYPE, SqlDbType.Int); parameterObjectType.Value = obj.ObjectType; parameterObjectType.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterObjectType); SqlParameter parameterType = new SqlParameter(PN_TYPE, SqlDbType.Int); parameterType.Value = obj.Type; parameterType.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterType); SqlParameter parameterStatus = new SqlParameter(PN_STATUS, SqlDbType.Int); parameterStatus.Value = obj.Status; parameterStatus.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterStatus); SqlParameter parameterIsDeleted = new SqlParameter(PN_ISDELETED, SqlDbType.Int); parameterIsDeleted.Value = obj.IsDeleted; parameterIsDeleted.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterIsDeleted); SqlParameter parameterIntialValue = new SqlParameter(PN_INTIALVALUE, SqlDbType.NVarChar); parameterIntialValue.Value = obj.IntialValue; parameterIntialValue.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterIntialValue); SqlParameter parameterModifiedValue = new SqlParameter(PN_MODIFIEDVALUE, SqlDbType.NVarChar); parameterModifiedValue.Value = obj.ModifiedValue; parameterModifiedValue.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterModifiedValue); SqlParameter parameterIPAddress = new SqlParameter(PN_IPADDRESS, SqlDbType.NVarChar); parameterIPAddress.Value = obj.IPAddress; parameterIPAddress.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterIPAddress); #endregion; _connection.Open(); _command.ExecuteNonQuery(); _connection.Close(); obj.ID = Convert.ToInt32(parameterID.Value); return obj.ID; }
public IList<Comment> GetPendingComments() { Comment obj = null; IList<Comment> colobj = new List<Comment>(); _connection.ConnectionString = _ConnectionString; _command.Connection = _connection; _command.CommandType = CommandType.StoredProcedure; _command.CommandText = "[usp_SelectCommentsAllPending]"; _connection.Open(); try { using (_dtreader = _command.ExecuteReader()) { if (_dtreader != null && _dtreader.HasRows) { obj = new Comment(); colobj = new List<Comment>(); while (_dtreader.Read()) { obj = GetComment(_dtreader, colobj); GetEntityFromReader(_dtreader, obj); } } } } catch (Exception ex) { throw ex; } finally { _dtreader.Close(); _connection.Close(); } return colobj; }
public IList<Comment> GetCommentsByTypeandID(int ObjectID, int ObjectType) { Comment obj = null; IList<Comment> colobj = new List<Comment>(); _connection.ConnectionString = _ConnectionString; _command.Connection = _connection; _command.CommandType = CommandType.StoredProcedure; _command.CommandText = "[usp_SelectCommentsByTypeandID]"; #region [Parameters] SqlParameter parameterobjID = new SqlParameter(PN_OBJECTID, SqlDbType.Int); parameterobjID.Value = ObjectID; parameterobjID.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterobjID); SqlParameter parameterobjtype = new SqlParameter(PN_OBJECTTYPE, SqlDbType.Int); parameterobjtype.Value = ObjectType; parameterobjtype.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterobjtype); #endregion; _connection.Open(); try { using (_dtreader = _command.ExecuteReader()) { if (_dtreader != null && _dtreader.HasRows) { obj = new Comment(); colobj = new List<Comment>(); while (_dtreader.Read()) { obj = GetComment(_dtreader, colobj); GetEntityFromReader(_dtreader, obj); } } } } catch (Exception ex) { throw ex; } finally { _dtreader.Close(); _connection.Close(); } return colobj; }
public IList<Comment> SearchNewsComment(int objectid, int categoryid) { Comment obj = null; IList<Comment> colobj = new List<Comment>(); _connection.ConnectionString = _ConnectionString; _command.Connection = _connection; _command.CommandType = CommandType.StoredProcedure; _command.CommandText = "[usp_SelectCommentsByNewsCategoryandObjectID]"; #region [Parameters] SqlParameter parameterobjID = new SqlParameter(PN_OBJECTID, SqlDbType.Int); parameterobjID.Value = objectid; parameterobjID.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterobjID); SqlParameter parametercategoryid = new SqlParameter(NewsItemDataMapper.PN_CATEGORYID, SqlDbType.Int); parametercategoryid.Value = categoryid; parametercategoryid.Direction = ParameterDirection.Input; _command.Parameters.Add(parametercategoryid); #endregion; _connection.Open(); try { using (_dtreader = _command.ExecuteReader()) { if (_dtreader != null && _dtreader.HasRows) { obj = new Comment(); colobj = new List<Comment>(); while (_dtreader.Read()) { obj = GetComment(_dtreader, colobj); GetEntityFromReader(_dtreader, obj); } } } } catch (Exception ex) { throw ex; } finally { _dtreader.Close(); _connection.Close(); } return colobj; }
private void GetEntityFromReader(SqlDataReader _dtr, Comment obj) { PopulateComment(_dtr, obj); }
public Comment GetByID(int ID) { Comment obj = null; _connection.ConnectionString = _ConnectionString; _command.Connection = _connection; _command.CommandType = CommandType.StoredProcedure; _command.CommandText = SELECTComment; #region [Parameters] SqlParameter parameterID = new SqlParameter(PN_ID, SqlDbType.Int); parameterID.Value = ID; parameterID.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterID); #endregion; _connection.Open(); try { using (_dtreader = _command.ExecuteReader()) { if (_dtreader != null && _dtreader.HasRows) { obj = new Comment(); if (_dtreader.Read()) GetEntityFromReader(_dtreader, obj); } } } catch (Exception ex) { throw ex; } finally { _dtreader.Close(); _connection.Close(); } return obj; }
public static void Update(Comment obj) { CommentDataMapper objCaller = new CommentDataMapper(); objCaller.Update(obj); }
public static int Add(Comment obj) { CommentDataMapper objCaller = new CommentDataMapper(); return objCaller.Add(obj); }