private static bool AddPromotionAdsToPromotion(Promotion promo, CampaignSetupModel model, int customerFk,
                                                     CampaignSetupModel oldModel, out List<PromotionAd> addAds, out List<int> updateAds, out List<int> deleteAds)
 {
     deleteAds = new List<int>();
     updateAds = new List<int>();
     addAds = new List<PromotionAd>();
     bool shouldscheduleAds = false;
     foreach (PromotionAd pad in model.AdModelProp.Ads)
     {
         if (pad.Delete && pad.PromotionAdsPK != 0 && !pad.HasBeenSaved)
         {
             var singlePromo = promo.PromotionAds.Single(id => id.PromotionAdsPK == pad.PromotionAdsPK);
             if (singlePromo != null)
             {
                 deleteAds.Add(pad.PromotionAdsPK);
                 shouldscheduleAds = true;
             }
         }
         else if (!pad.Delete && pad.PromotionAdsPK == 0 && !pad.HasBeenSaved)
         {
             shouldscheduleAds = true;
             addAds.Add(pad);
             pad.AdTextLine1 = pad.AdTextLine1;
             pad.AdTextLine2 = pad.AdTextLine2;
             pad.AdTitle = pad.AdTitle;
             var cad = new PromotionAd
                           {
                               AdTextLine1 = pad.AdTextLine1,
                               AdTextLine2 = pad.AdTextLine2,
                               AdTitle = pad.AdTitle,
                               PromotionAdsPK = pad.PromotionAdsPK,
                               CreatedDate = DateTime.Now
                           };
             promo.PromotionAds.Add(cad);
         }
         else if (!pad.Delete && pad.PromotionAdsPK != 0)
         {
             var padOld = oldModel.AdModelProp.Ads.Single(x => x.PromotionAdsPK == pad.PromotionAdsPK);
             if (padOld != null)
             {
                 if (padOld.AdTextLine1 != pad.AdTextLine1 ||
                     padOld.AdTextLine2 != pad.AdTextLine2 ||
                     padOld.AdTitle != pad.AdTitle)
                 {
                     shouldscheduleAds = true;
                     updateAds.Add(pad.PromotionAdsPK);
                     var pa = promo.PromotionAds.Single(x => x.PromotionAdsPK == pad.PromotionAdsPK);
                     pa.AdTextLine1 = pad.AdTextLine1;
                     pa.AdTextLine2 = pad.AdTextLine2;
                     pa.AdTitle = pad.AdTitle;
                 }
             }
         }
     }
     return shouldscheduleAds;
 }
        public void AddPromotionAdsToPromotion(Promotion promo, CampaignSetupModel model, int customerFk)
        {
            foreach (PromotionAd pad in model.AdModelProp.Ads.Where(t => !t.Delete))
            {
                var cad = new PromotionAd { AdTextLine1 = pad.AdTextLine1, AdTextLine2 = pad.AdTextLine2, AdTitle = pad.AdTitle };

                //if (pad.SiteLinks != null)
                //{
                //    // add sitelinks
                //    foreach (SiteLink slink in pad.SiteLinks)
                //    {
                //        // this is check should be removed once we fix the logic in partialview and model
                //        if (!String.IsNullOrEmpty(slink.LinkText) && !String.IsNullOrEmpty(slink.LinkURL))
                //        {
                //            var slinkobj = new SiteLink { LinkText = slink.LinkText, LinkURL = slink.LinkURL };
                //            cad.SiteLinks.Add(slinkobj);
                //        }
                //    }
                //}

                promo.PromotionAds.Add(cad);
                try
                {
                    var sw = new ServiceClientWrapper();
                    var adEngines = new List<string>();
                    var promoAds = new List<int>();
                    if (promo.IsLaunched)
                    {
                        adEngines.AddRange(promo.PromotionAdEngineSelecteds.Select(pades => pades.AdvertisingEngine.AdvertisingEngine1));
                        promoAds.AddRange(promo.PromotionAds.Select(pa => pa.PromotionAdsPK));
                        sw.scheduleAds(customerFk, promo.PromotionPK, promoAds, adEngines, true);
                    }
                }
                catch (Exception ex) { SharedResources.Helpers.ExceptionHelper.LogException(ex.ToString()); }
            }
        }