Esempio n. 1
0
 public ActionResult KeyWords(CampaignSetupModel model, FormCollection fc)
 {
     try
     {
         int userid = ((Credential) (Session[SharedResources.SEMplestConstants.SESSION_USERID])).UsersFK;
         var dbcontext = new SemplestModel.Semplest();
         var promoRepository = new PromotionRepository(dbcontext);
         var promoId = promoRepository.GetPromotionId(userid, model.ProductGroup.ProductGroupName,
                                                          model.ProductGroup.ProductPromotionName);
         _campaignRepository.SetKeywordsDeleted(model.KeywordIds, promoId);
         var sessionModel = (CampaignSetupModel) Session["CampaignSetupModel"];
         sessionModel.AllKeywords.RemoveAll(key => model.KeywordIds.Contains(key.Id));
         model.BillingLaunch.KeywordsCount = sessionModel.AllKeywords.Count();
         Session["CampaignSetupModel"] = sessionModel;
         //model = sessionModel;
         return Json(new {count = model.BillingLaunch.KeywordsCount, name = "Keywords"});
     }
     catch (Exception ex)
     {
         ExceptionHelper.LogException(ex);
         return Json(ExceptionHelper.GetErrorMessage(ex));
     }
 }
Esempio n. 2
0
 public ActionResult CreateAds()
 {
     int userid = ((Credential) (Session[SharedResources.SEMplestConstants.SESSION_USERID])).UsersFK;
     var sessModel = (CampaignSetupModel)Session["CampaignSetupModel"];
     var dbcontext = new SemplestModel.Semplest();
     var promoRepository = new PromotionRepository(dbcontext);
     var promoid = promoRepository.GetPromotionId(userid, sessModel.ProductGroup.ProductGroupName, sessModel.ProductGroup.ProductPromotionName);
     var campaignModel = _campaignRepository.GetCampaignSetupModelForPromotionId(promoid);
     Session["CampaignSetupModel"] = campaignModel;
     return PartialView("EditorTemplates/AdModel", campaignModel.AdModelProp);
 }
Esempio n. 3
0
 public ActionResult Categories()
 {
     var model = (CampaignSetupModel)Session["CampaignSetupModel"];
     model.AllCategories = (List<CampaignSetupModel.CategoriesModel>) Session["AllCategories"];
     if (model.AllCategories == null)
     {
         model.AllCategories =new List<CampaignSetupModel.CategoriesModel>();
         model = _campaignRepository.GetCategories((CampaignSetupModel) Session["CampaignSetupModel"]);
         if (model == null)
         {
             ViewData["TechnicalDifficulties"] = ConfigurationManager.AppSettings["TechnicalDifficulties"];
             return PartialView(null);
         }
         Session["CampaignSetupModel"] = model;
         Session["AllCategories"] = model.AllCategories;
     }
     int userid = ((Credential) (Session[SharedResources.SEMplestConstants.SESSION_USERID])).UsersFK;
     var dbcontext = new SemplestModel.Semplest();
     var promoRepository = new PromotionRepository(dbcontext);
     var promoId = promoRepository.GetPromotionId(userid, model.ProductGroup.ProductGroupName,
                                                      model.ProductGroup.ProductPromotionName);
     var dbContext = new SemplestModel.Semplest();
     var cats = dbContext.KeywordCategories.Where(x => x.PromotionFK == promoId);
     var i = 0;
     if (cats.Any())
     {
         foreach (CampaignSetupModel.CategoriesModel cm in model.AllCategories)
         {
             if (cats.Any(x => x.KeywordCategory1 == cm.Name))
                 model.CategoryIds.Add(i);
             i += 1;
         }
     }
     return PartialView(model);
 }
Esempio n. 4
0
        public ActionResult GetKeywords(CampaignSetupModel model)
        {
            try
            {
                model.AllCategories = (List<CampaignSetupModel.CategoriesModel>)Session["AllCategories"];
                model.AdModelProp.NegativeKeywords = (List<string>)Session["NegativeKeywords"];
                model.AdModelProp.NegativeKeywordsText = (string)Session["NegativeKeywordsText"];

                if (!model.CategoryIds.Any())
                    return Json("At least one category needs to be selected");


                // get selected categories
                var catList = new List<string>();
                foreach (var cat in model.AllCategories)
                {
                    catList.AddRange(from t in model.CategoryIds where cat.Id == t select cat.Name);
                }

                // save the selected categories here
                //int userid = (int)Session[Semplest.SharedResources.SEMplestConstants.SESSION_USERID];
                int userid =
                    ((Credential)(Session[SharedResources.SEMplestConstants.SESSION_USERID])).UsersFK;

                var dbcontext = new SemplestModel.Semplest();
                var promotionRepository = new PromotionRepository(dbcontext);
                var promoId = promotionRepository.GetPromotionId(userid, model.ProductGroup.ProductGroupName,
                                                model.ProductGroup.ProductPromotionName);
                _campaignRepository.SaveSelectedCategories(promoId, catList);
                model = _campaignRepository.GetKeyWords(model, promoId);
                if (model != null)
                {
                    model.BillingLaunch.KeywordsCount =
                        model.AllKeywordProbabilityObjects.Count(x => x.isDeleted == false);
                    Session.Add("CampaignSetupModel", model);
                    return Json("Billing & Launch");
                }
                return Json(ConfigurationManager.AppSettings["TechnicalDifficulties"]);
            }
            catch (Exception ex)
            {
                ExceptionHelper.LogException(ex);
                return Json(ConfigurationManager.AppSettings["TechnicalDifficulties"]);
            }
        }