Exemplo n.º 1
0
        public ActionResult Create(PromotionCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var svc = CreatePromotionService();

            if (svc.CreatePromotion(model))
            {
                TempData["SaveResult"] = "Your PlanItem was promoted.";
                return(RedirectToAction("Details", "Project", new { id = new PlanItemService(Guid.Parse(UserHelper.GetUserId())).GetProjectIdFor(model.PlanId) }));
            }
            return(View(model));
        }
        public bool CreatePromotion(PromotionCreate model)
        {
            var entity = new Promotion()
            {
                OwnerId       = _userId,
                PromotionName = model.PromotionName,
                DateFounded   = model.DateFounded.Date,
                Website       = model.Website,
                CreatedUtc    = DateTimeOffset.Now
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Promotions.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Exemplo n.º 3
0
        public bool CreatePromotion(PromotionCreate model)
        {
            var entity = new PlanItemPromotion
            {
                PromotionId     = Guid.NewGuid(),
                PlanId          = model.PlanId,
                Summary         = model.Summary,
                Details         = model.Detail,
                DateImplemented = DateTimeOffset.Now,
                OldCategory     = model.FromCategory,
                NewCategory     = model.ToCategory
            };

            Context.Promotions.Add(entity);
            var entx = Context.PlanItems.Where(e => e.PlanItemID == model.PlanId).Single();

            entx.Category = model.ToCategory;
            return(Context.TrySave());
        }
Exemplo n.º 4
0
        public ActionResult Create(PromotionCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreatePromotionService();

            if (service.CreatePromotion(model))
            {
                TempData["SaveResult"] = "Your promotion has been created!";
                return(RedirectToAction("Index"));
            }
            ;

            ModelState.AddModelError("", "Promotion could not be created.");

            return(View(model));
        }
Exemplo n.º 5
0
        public ActionResult Create(Guid planItemId)
        {
            var model = new PromotionCreate(new PlanItemService(Guid.Parse(UserHelper.GetUserId())).GetPlanItemById(planItemId));

            return(View(model));
        }