Beispiel #1
0
        public ActionResult AddCampaign(FormCollection collection)
        {
            if (Session["userKey"] != null)
            {
                try
                {
                    pcms_campaign campaign = new pcms_campaign();
                    campaign.CAMPAIGN_NAME = collection["campaign_name"].ToString();
                    string[] s = collection["startdate"].ToString().Split('/');
                    campaign.CAMPAIGN_START_DATE = Convert.ToDateTime(s[2] + "/" + s[0] + "/" + s[1]);
                    string[] s1 = collection["endDate"].ToString().Split('/');
                    campaign.CAMPAIGN_END_DATE     = Convert.ToDateTime(s1[2] + "/" + s1[0] + "/" + s1[1]);
                    campaign.CAMPAIGN_DESCRIPTION  = Convert.ToString(collection["Description"]);
                    campaign.CAMPAIGN_URL          = collection["campaignurl"].ToString();
                    campaign.CAMPAIGN_DESIGN_ID    = collection["designlist"] == "" ? 0 : Convert.ToInt16(collection["designlist"]);
                    campaign.CAMPAIGN_CONTENT_ID   = collection["contentlist"] == "" ? 0 : Convert.ToInt16(collection["contentlist"]);
                    campaign.CAMPAIGN_POPUP_ID     = Convert.ToInt16(Convert.ToString(collection["popuplist"]));
                    campaign.CAMPAIGN_CONTAINER_ID = Convert.ToString(collection["containerid"]);
                    campaign.CAMPAIGN_STATUS       = Convert.ToString(collection["campaingstatus"]);
                    campaign.CAMPAIGN_REDIRECT_URL = Convert.ToString(collection["redirecturl"]);
                    campaign.CAMPAIGN_RULE_ID      = Convert.ToInt16(collection["rulelister"]);
                    campaign.CAMPAIGN_POPUP_STATUS = Convert.ToString(collection["popup"]);
                    campaign.INSERTED_BY           = Session["userKey"].ToString();
                    campaign.INSERTED_DATE         = DateTime.Now;
                    campaign.TS_CNT = 0;
                    var campaigner = objBAL.AddCampain(campaign);

                    if (campaigner.Contains("Inserted"))
                    {
                        ViewBag.Message = "Campaign Inserted";
                    }
                    else if (campaigner.Contains("Duplicate"))
                    {
                        ViewBag.Message = "Campaign name must be unique";
                    }
                    else
                    {
                        ViewBag.Message = "Something went wrong";
                    }
                    return(View());
                }
                catch (Exception ex)
                {
                    ErrorLog obj = new ErrorLog();
                    obj.LogError(ex);
                    return(null);
                }
            }
            else
            {
                return(RedirectToAction("Index", "Account", null));
            }
        }
Beispiel #2
0
        public string InsertCampaignData(pcms_campaign _campaign)
        {
            string         Msg     = "";
            PCMS_DbContext context = new PCMS_DbContext();

            try
            {
                if (!context.pcms_campaign.Any(u => u.CAMPAIGN_NAME == _campaign.CAMPAIGN_NAME))
                {
                    pcms_campaign cm = new pcms_campaign();
                    cm.PK_CAMPAIGN           = Guid.NewGuid();
                    cm.CAMPAIGN_NAME         = _campaign.CAMPAIGN_NAME;
                    cm.CAMPAIGN_DESCRIPTION  = Cryptographys.Encrypt(_campaign.CAMPAIGN_DESCRIPTION);
                    cm.CAMPAIGN_START_DATE   = Convert.ToDateTime(_campaign.CAMPAIGN_START_DATE);
                    cm.CAMPAIGN_END_DATE     = Convert.ToDateTime(_campaign.CAMPAIGN_END_DATE);
                    cm.CAMPAIGN_STATUS       = _campaign.CAMPAIGN_STATUS;
                    cm.CAMPAIGN_DESIGN_ID    = _campaign.CAMPAIGN_DESIGN_ID;
                    cm.CAMPAIGN_CONTENT_ID   = _campaign.CAMPAIGN_CONTENT_ID;
                    cm.CAMPAIGN_POPUP_STATUS = _campaign.CAMPAIGN_POPUP_STATUS;
                    cm.CAMPAIGN_POPUP_ID     = _campaign.CAMPAIGN_POPUP_ID;
                    cm.CAMPAIGN_RULE_ID      = _campaign.CAMPAIGN_RULE_ID;
                    cm.CAMPAIGN_URL          = Cryptographys.Encrypt(_campaign.CAMPAIGN_URL);
                    cm.CAMPAIGN_REDIRECT_URL = Cryptographys.Encrypt(_campaign.CAMPAIGN_REDIRECT_URL);
                    cm.CAMPAIGN_CONTAINER_ID = _campaign.CAMPAIGN_CONTAINER_ID;
                    cm.INSERTED_BY           = _campaign.INSERTED_BY;
                    cm.INSERTED_DATE         = _campaign.INSERTED_DATE;
                    cm.TS_CNT = _campaign.TS_CNT;
                    context.AddTopcms_campaign(cm);
                    context.SaveChanges();
                    Msg = "Inserted";
                }
                else
                {
                    Msg = "Duplicate";
                }
                return(Msg);
            }
            catch (Exception ex)
            {
                Utilities objUtilities = new Utilities();
                objUtilities.LogError(ex);
                Msg = "Something went wrong";
                return(null);
            }
        }
Beispiel #3
0
        public string UpdateCamaign(pcms_campaign _campaign)
        {
            string Msg = "";

            try
            {
                using (PCMS_DbContext _pcmsDbContext = new PCMS_DbContext())
                {
                    //Perform Update operation
                    pcms_campaign cm = _pcmsDbContext.pcms_campaign.Single(u => u.CAMPAIGN_ID == _campaign.CAMPAIGN_ID);
                    cm.CAMPAIGN_NAME         = _campaign.CAMPAIGN_NAME;
                    cm.CAMPAIGN_DESCRIPTION  = Cryptographys.Encrypt(_campaign.CAMPAIGN_DESCRIPTION);
                    cm.CAMPAIGN_START_DATE   = Convert.ToDateTime(_campaign.CAMPAIGN_START_DATE);
                    cm.CAMPAIGN_END_DATE     = Convert.ToDateTime(_campaign.CAMPAIGN_END_DATE);
                    cm.CAMPAIGN_STATUS       = _campaign.CAMPAIGN_STATUS;
                    cm.CAMPAIGN_DESIGN_ID    = _campaign.CAMPAIGN_DESIGN_ID;
                    cm.CAMPAIGN_CONTENT_ID   = _campaign.CAMPAIGN_CONTENT_ID;
                    cm.CAMPAIGN_POPUP_STATUS = _campaign.CAMPAIGN_POPUP_STATUS;
                    cm.CAMPAIGN_POPUP_ID     = _campaign.CAMPAIGN_POPUP_ID;
                    cm.CAMPAIGN_RULE_ID      = _campaign.CAMPAIGN_RULE_ID;
                    cm.CAMPAIGN_URL          = Cryptographys.Encrypt(_campaign.CAMPAIGN_URL);
                    cm.CAMPAIGN_REDIRECT_URL = Cryptographys.Encrypt(_campaign.CAMPAIGN_REDIRECT_URL);
                    cm.CAMPAIGN_CONTAINER_ID = _campaign.CAMPAIGN_CONTAINER_ID;
                    cm.INSERTED_BY           = _campaign.INSERTED_BY;
                    cm.INSERTED_DATE         = _campaign.INSERTED_DATE;
                    cm.TS_CNT = _campaign.TS_CNT;
                    _pcmsDbContext.SaveChanges();
                    Msg = "Updated";
                    return(Msg);
                }
            }
            catch (Exception ex)
            {
                Utilities objUtilities = new Utilities();
                objUtilities.LogError(ex);
                Msg = "Something went wrong";
                return(null);
            }
        }
Beispiel #4
0
 public string AddCampain(pcms_campaign _campaign)
 {
     return(objDAL.InsertCampaignData(_campaign));
 }
Beispiel #5
0
 public string UpdateCamaign(pcms_campaign campaign)
 {
     return(objDAL.UpdateCamaign(campaign));
 }