private DBCampaign GetCampaignFromReader(IDataReader dataReader)
 {
     DBCampaign campaign = new DBCampaign();
     campaign.CampaignID = NopSqlDataHelper.GetInt(dataReader, "CampaignID");
     campaign.Name = NopSqlDataHelper.GetString(dataReader, "Name");
     campaign.Subject = NopSqlDataHelper.GetString(dataReader, "Subject");
     campaign.Body = NopSqlDataHelper.GetString(dataReader, "Body");
     campaign.CreatedOn = NopSqlDataHelper.GetUtcDateTime(dataReader, "CreatedOn");
     return campaign;
 }
        private DBCampaign GetCampaignFromReader(IDataReader dataReader)
        {
            var item = new DBCampaign();

            item.CampaignId = NopSqlDataHelper.GetInt(dataReader, "CampaignID");
            item.Name       = NopSqlDataHelper.GetString(dataReader, "Name");
            item.Subject    = NopSqlDataHelper.GetString(dataReader, "Subject");
            item.Body       = NopSqlDataHelper.GetString(dataReader, "Body");
            item.CreatedOn  = NopSqlDataHelper.GetUtcDateTime(dataReader, "CreatedOn");
            return(item);
        }
Esempio n. 3
0
        private DBCampaign GetCampaignFromReader(IDataReader dataReader)
        {
            DBCampaign campaign = new DBCampaign();

            campaign.CampaignID = NopSqlDataHelper.GetInt(dataReader, "CampaignID");
            campaign.Name       = NopSqlDataHelper.GetString(dataReader, "Name");
            campaign.Subject    = NopSqlDataHelper.GetString(dataReader, "Subject");
            campaign.Body       = NopSqlDataHelper.GetString(dataReader, "Body");
            campaign.CreatedOn  = NopSqlDataHelper.GetUtcDateTime(dataReader, "CreatedOn");
            return(campaign);
        }
        private static Campaign DBMapping(DBCampaign dbItem)
        {
            if (dbItem == null)
                return null;

            Campaign item = new Campaign();
            item.CampaignID = dbItem.CampaignID;
            item.Name = dbItem.Name;
            item.Subject = dbItem.Subject;
            item.Body = dbItem.Body;
            item.CreatedOn = dbItem.CreatedOn;

            return item;
        }
Esempio n. 5
0
        /// <summary>
        /// Gets all campaigns
        /// </summary>
        /// <returns>Campaign collection</returns>
        public override DBCampaignCollection GetAllCampaigns()
        {
            DBCampaignCollection campaignCollection = new DBCampaignCollection();
            Database             db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand            dbCommand = db.GetStoredProcCommand("Nop_CampaignLoadAll");

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    DBCampaign campaign = GetCampaignFromReader(dataReader);
                    campaignCollection.Add(campaign);
                }
            }
            return(campaignCollection);
        }
Esempio n. 6
0
        /// <summary>
        /// Inserts a campaign
        /// </summary>
        /// <param name="Name">The name</param>
        /// <param name="Subject">The subject</param>
        /// <param name="Body">The body</param>
        /// <param name="CreatedOn">The date and time of instance creation</param>
        /// <returns>Campaign</returns>
        public override DBCampaign InsertCampaign(string Name, string Subject, string Body, DateTime CreatedOn)
        {
            DBCampaign campaign  = null;
            Database   db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand  dbCommand = db.GetStoredProcCommand("Nop_CampaignInsert");

            db.AddOutParameter(dbCommand, "CampaignID", DbType.Int32, 0);
            db.AddInParameter(dbCommand, "Name", DbType.String, Name);
            db.AddInParameter(dbCommand, "Subject", DbType.String, Subject);
            db.AddInParameter(dbCommand, "Body", DbType.String, Body);
            db.AddInParameter(dbCommand, "CreatedOn", DbType.DateTime, CreatedOn);
            if (db.ExecuteNonQuery(dbCommand) > 0)
            {
                int CampaignID = Convert.ToInt32(db.GetParameterValue(dbCommand, "@CampaignID"));
                campaign = GetCampaignByID(CampaignID);
            }
            return(campaign);
        }
        /// <summary>
        /// Updates the campaign
        /// </summary>
        /// <param name="campaignId">The campaign identifier</param>
        /// <param name="name">The name</param>
        /// <param name="subject">The subject</param>
        /// <param name="body">The body</param>
        /// <param name="createdOn">The date and time of instance creation</param>
        /// <returns>Campaign</returns>
        public override DBCampaign UpdateCampaign(int campaignId,
                                                  string name, string subject, string body, DateTime createdOn)
        {
            DBCampaign item      = null;
            Database   db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand  dbCommand = db.GetStoredProcCommand("Nop_CampaignUpdate");

            db.AddInParameter(dbCommand, "CampaignID", DbType.Int32, campaignId);
            db.AddInParameter(dbCommand, "Name", DbType.String, name);
            db.AddInParameter(dbCommand, "Subject", DbType.String, subject);
            db.AddInParameter(dbCommand, "Body", DbType.String, body);
            db.AddInParameter(dbCommand, "CreatedOn", DbType.DateTime, createdOn);
            if (db.ExecuteNonQuery(dbCommand) > 0)
            {
                item = GetCampaignById(campaignId);
            }

            return(item);
        }
        /// <summary>
        /// Gets a campaign by campaign identifier
        /// </summary>
        /// <param name="campaignId">Campaign identifier</param>
        /// <returns>Message template</returns>
        public override DBCampaign GetCampaignById(int campaignId)
        {
            DBCampaign item = null;

            if (campaignId == 0)
            {
                return(item);
            }
            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_CampaignLoadByPrimaryKey");

            db.AddInParameter(dbCommand, "CampaignID", DbType.Int32, campaignId);
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    item = GetCampaignFromReader(dataReader);
                }
            }
            return(item);
        }