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 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. 3
0
 public ActionResult LaunchAdProduct(CampaignSetupModel model)
 {
     try
     {
         var dbContext = new SemplestModel.Semplest();
         var cr = new CreditCardRepository(dbContext);
         var sr = new StateRepository(dbContext);
         var pr = new PromotionRepository(dbContext);
         var bt = new BillTypeRepository(dbContext);
         var promo = pr.GetPromoitionFromCampaign(GetCustomerId(), model.ProductGroup.ProductGroupName,
                                                  model.ProductGroup.ProductPromotionName);
         var retVal = new ReturnState(false,false,"Not a credit card customer", null);
         if (model.BillType == bt.GetBillTypeCode("Credit Card"))
         {
             retVal = cr.ChargeCreditCard(new CustomerObject
                                                  {
                                                      Address1 = model.BillingLaunch.Address,
                                                      City = model.BillingLaunch.City,
                                                      Email = model.BillingLaunch.Email,
                                                      StateAbbr =
                                                          sr.GetStateNameFromCode(
                                                              int.Parse(model.BillingLaunch.StateCodeFK)),
                                                      ExpireDateMMYY =
                                                          model.BillingLaunch.ExpiryMonth +
                                                          model.BillingLaunch.ExpiryYear,
                                                      FirstName = model.BillingLaunch.FirstName,
                                                      LastName = model.BillingLaunch.LastName,
                                                      Phone = model.BillingLaunch.Phone,
                                                      ZipCode = model.BillingLaunch.Zip,
                                                      creditCardNumber = model.BillingLaunch.CardNumber
                                                  }, promo, model.BillType, model.ProductGroup.Budget);
         }
         try
         {
             if (!retVal.IsException && !retVal.IsValidationError)
             {
                 dbContext.SaveChanges();
                 var adEngines = new List<string>();
                 adEngines.AddRange(
                     promo.PromotionAdEngineSelecteds.Select(
                         pades => pades.AdvertisingEngine.AdvertisingEngine1));
                 var sw = new ServiceClientWrapper();
                 if (sw.ScheduleAddPromotionToAdEngine(GetCustomerId(), promo.ProductGroupFK,
                                                       promo.PromotionPK, adEngines.ToArray()))
                 {
                     pr.SetPromotionToLaunched(promo.PromotionPK);
                     dbContext.SaveChanges();
                 }
                 return Json(retVal.ReturnMessage);
             }
         }
         catch (Exception ex)
         {
             ExceptionHelper.LogException(ex);
             return Json(retVal.ReturnMessage);
         }
         if (!retVal.IsException && retVal.IsValidationError)
             return Json("Validation Error<~> " + retVal.ReturnMessage);
     }
     catch (Exception ex)
     {
         ExceptionHelper.LogException(ex);
     }
     return Json(ConfigurationManager.AppSettings["TechnicalDifficulties"]);
 }
Esempio n. 4
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. 5
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"]);
            }
        }