Ejemplo n.º 1
0
 private List<GeoTargetObject> SerializeToGeoTargetObjectArray(CampaignSetupModel model)
 {
     var geoList = new List<GeoTargetObject>();
     var sr = new StateRepository();
     foreach (var geo in model.AdModelProp.Addresses)
     {
         if (!geo.IsState && !geo.Delete && !geo.IsCountry)
         {
             var geoTObj = new GeoTargetObject();
             geoTObj.address = geo.Address;
             geoTObj.city = geo.City;
             if (geo.StateCodeFK != int.MinValue) geoTObj.state = sr.GetStateNameFromCode((int)geo.StateCodeFK);
             geoTObj.zip = geo.Zip;
             geoTObj.radius = (double?)(geo.ProximityRadius ?? null);
             geoTObj.latitude = (double?)(geo.Latitude ?? null);
             geoTObj.longitude = (double?)(geo.Longitude ?? null);
             geoList.Add(geoTObj);
         }
     }
     return geoList;
 }
Ejemplo n.º 2
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"]);
 }