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); } }
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()); }
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)); }
public ActionResult Create(Guid planItemId) { var model = new PromotionCreate(new PlanItemService(Guid.Parse(UserHelper.GetUserId())).GetPlanItemById(planItemId)); return(View(model)); }