public virtual MessageContentCollection GetMessageContentList(int status, MessageContentColumns orderBy, string orderDirection, int page, int pageSize, out int totalRecords) { try { Database database = DatabaseFactory.CreateDatabase("CustommerServiceConnection"); DbCommand dbCommand = database.GetStoredProcCommand("spMessageContentGetListByStatus"); database.AddInParameter(dbCommand, "@Status", DbType.Int32, status); database.AddInParameter(dbCommand, "@OrderBy", DbType.AnsiString, orderBy.ToString()); database.AddInParameter(dbCommand, "@OrderDirection", DbType.AnsiString, orderDirection.ToString()); database.AddInParameter(dbCommand, "@Page", DbType.Int32, page); database.AddInParameter(dbCommand, "@PageSize", DbType.Int32, pageSize); database.AddOutParameter(dbCommand, "@TotalRecords", DbType.Int32, 4); MessageContentCollection messageContentCollection = new MessageContentCollection(); using (IDataReader reader = database.ExecuteReader(dbCommand)) { while (reader.Read()) { MessageContent messageContent = CreateMessageContentFromReader(reader); messageContentCollection.Add(messageContent); } reader.Close(); } totalRecords = (int)database.GetParameterValue(dbCommand, "@TotalRecords"); return messageContentCollection; } catch (Exception ex) { // log this exception log4net.Util.LogLog.Error(ex.Message, ex); // wrap it and rethrow throw new ApplicationException(SR.DataAccessGetMessageContentListException, ex); } }
public virtual MessageContentCollection ExistsContentTemplateForMessageContent(int ContentTemplateID) { try { Database database = DatabaseFactory.CreateDatabase("CustommerServiceConnection"); DbCommand dbCommand = database.GetStoredProcCommand("spContentTemplateForMessageContent"); database.AddInParameter(dbCommand, "@ContentTemplateID", DbType.Int32, ContentTemplateID); MessageContentCollection messageContentCollection = new MessageContentCollection(); using (IDataReader reader = database.ExecuteReader(dbCommand)) { while (reader.Read()) { MessageContent messageContent = CreateMessageContentFromReader(reader); messageContentCollection.Add(messageContent); } reader.Close(); } return messageContentCollection; } catch (Exception ex) { // log this exception log4net.Util.LogLog.Error(ex.Message, ex); // wrap it and rethrow throw new ApplicationException(SR.DataAccessGetMessageContentListException, ex); } }