Ejemplo n.º 1
0
        public ActionResult Create(PromoCreateModel pcm)
        {
            this.AccountBase.SetupActionAccount();

            //if (ModelState.IsValid)
            //{
            //try
            //{
            pcm.AccountBase = this.AccountBase;
            var success = pcm.CreatePromotion();
            if (success)
            {
                return View("Index");
            }
            else
            {
                return View(pcm);
            }
            //}
            //catch
            //{
            //    return View(pcm);
            //}
            //}
            //else
            //{
            //    return View(pcm);
            //}
        }
Ejemplo n.º 2
0
 public ActionResult Create(Guid? businessId)
 {
     if (businessId.HasValue)
     {
         var pcm = new PromoCreateModel(this.AccountBase, businessId.Value, new ModelEntities.Promotion());
         pcm.Setup();
         return View(pcm);
     }
     else
     {
         return View("Error");
     }
 }
Ejemplo n.º 3
0
        public ActionResult PromotionCreate(PromoCreateModel pcm)
        {
            this.AccountBase.SetupActionAccount();

            // Because of the weird control, we fetch deals from a json param:
            string jsonDeal = Request.Form["Deals"];
            // first try to serialize it as a single thing, then try as an array;
            dynamic deal = null;
            pcm.Promotion.Deals = new List<ModelEntities.Deal>();
            try
            {

                deal = jsonDeal.GetJson();
                var d = ConvertDynamicToDeal(deal);
                pcm.Promotion.Deals.Add(d);

            }
            catch (Exception)
            {
            }
            if (deal == null)
            {
                jsonDeal = "[" + jsonDeal + "]";
                deal = jsonDeal.GetJson();
                if (deal != null)
                {
                    foreach (dynamic foo in deal)
                    {
                        var d = ConvertDynamicToDeal(foo);
                        pcm.Promotion.Deals.Add(d);
                    }
                }
                else
                {
                    //error
                }
            }

            var p = AutoMapper.Mapper.Map<ModelEntities.Promotion, DataEntites.Promotion>(pcm.Promotion);

            List<PraLoup.DataAccess.Entities.Business> userbusinesses = new List<PraLoup.DataAccess.Entities.Business>();
            var userBusiness = AccountBase.BusinessActions.GetBusinessForUser(AccountBase.Account).FirstOrDefault();
            //TODO: we should throw exception here. this is error condition, the user should not create promotion without business
            p.Business = userbusinesses != null ? userBusiness : new DataEntites.Business();
            this.AccountBase.PromotionActions.SavePromotion(p);
            return View(pcm);
        }
Ejemplo n.º 4
0
 public ActionResult PromotionCreate()
 {
     var pcm = new PromoCreateModel();
     // pcm.Promotion.Deals.AddUserGroups(new List<UserGroup>());
     return View(pcm);
 }
Ejemplo n.º 5
0
        public ActionResult Edit(Guid id, PromoCreateModel pcm)
        {
            try
            {
                // TODO: Add update logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Ejemplo n.º 6
0
 //
 // GET: /Business/Promotion/Create
 public ActionResult Create(Guid businessId)
 {
     var pcm = new PromoCreateModel(this.AccountBase, businessId, new Entities.Promotion());
     pcm.Setup();
     return View(pcm);
 }