Exemplo n.º 1
0
 public ActionResult EndPromotion(int promotionIdE)
 {
     try
     {
         ServiceClientWrapper sw = new ServiceClientWrapper();
         SemplestModel.Semplest dbContext = new SemplestModel.Semplest();
         List<string> adEngines = new List<string>();
         Promotion p = dbContext.Promotions.Where(x => x.PromotionPK == promotionIdE).First();
         int customerId = ((Credential)Session[Semplest.SharedResources.SEMplestConstants.SESSION_USERID]).User.CustomerFK.Value;
         foreach (PromotionAdEngineSelected pades in p.PromotionAdEngineSelecteds)
             adEngines.Add(pades.AdvertisingEngine.AdvertisingEngine1);
         p.IsCompleted = sw.schedulePromotion(promotionIdE, adEngines.ToArray(), SEMplestConstants.SchedulePromotionType.End);
         dbContext.SaveChanges();
     }
     catch (Exception ex) { Semplest.SharedResources.Helpers.ExceptionHelper.LogException(ex); }
     return RedirectToAction("Index2");
 }
        public ActionResult RestartPromotions(int id)
        {
            SemplestModel.Semplest dbContext = new SemplestModel.Semplest();
            ServiceClientWrapper sw = new ServiceClientWrapper();
            foreach (ProductGroup pg in dbContext.Customers.Where(key => key.CustomerPK == id).First().ProductGroups)
            {
                foreach (Promotion p in pg.Promotions)
                {
                    if (p.IsLaunched && p.IsPaused && (!p.IsCompleted))
                    {
                        List<string> adEngines = new List<string>();
                        foreach (PromotionAdEngineSelected pades in p.PromotionAdEngineSelecteds)
                            adEngines.Add(pades.AdvertisingEngine.AdvertisingEngine1);
                        p.IsPaused = !sw.schedulePromotion(id, p.PromotionPK, adEngines.ToArray(), true);
                    }
                }
            }

            dbContext.SaveChanges();
            Dictionary<string, object> d = new Dictionary<string, object>();
            d.Add("id", id);
            return RedirectToAction("Index", new System.Web.Routing.RouteValueDictionary(d));
        }
Exemplo n.º 3
0
 public ActionResult RemovePromotion(int promotionId)
 {
     try
     {
         ServiceClientWrapper sw = new ServiceClientWrapper();
         SemplestModel.Semplest dbContext = new SemplestModel.Semplest();
         int customerId = ((Credential)Session[Semplest.SharedResources.SEMplestConstants.SESSION_USERID]).User.CustomerFK.Value;
         dbContext.Promotions.First(x => x.PromotionPK == promotionId).IsDeleted = sw.schedulePromotion(promotionId, dbContext.Promotions.First(x => x.PromotionPK == promotionId).PromotionAdEngineSelecteds.Select(pades => pades.AdvertisingEngine.AdvertisingEngine1).ToArray(), SEMplestConstants.SchedulePromotionType.Delete);
         dbContext.SaveChanges();
     }
     catch (Exception ex) { Semplest.SharedResources.Helpers.ExceptionHelper.LogException(ex); }
     return RedirectToAction("Index2");
 }