public ActionResult Edit( PromotionVM promotion) { if (ModelState.IsValid) { Promotion model = db.Promotions.Find(promotion.Id); PromotionCreator creator = db.PromotionCreators.Find(promotion.PromotionCreatorId); //promotion: model.Cost = promotion.Cost; model.Description = promotion.Description; model.Duration = promotion.Duration.Value; model.PromotionDate = promotion.PromotionDate.Value; model.PromotionType = promotion.PromotionType; model.Venue = promotion.Venue; //creator: creator.FirstName = promotion.FirstName; creator.Email = promotion.Email; creator.LastName = promotion.LastName; creator.PhoneNumber = promotion.PhoneNumber; db.Entry(model).State = EntityState.Modified; db.Entry(creator).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Costs = costs; ViewBag.PromotionTypes = promotionTypes; return(View(promotion)); }
// GET: Promotions/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Promotion promotion = db.Promotions.Find(id); if (promotion == null) { return(HttpNotFound()); } PromotionCreator creator = db.PromotionCreators.Find(promotion.PromotionCreatorId); PromotionVM prom = new PromotionVM() { Cost = promotion.Cost, Description = promotion.Description, Duration = promotion.Duration, Id = promotion.Id, PromotionCreatorId = promotion.PromotionCreatorId, PromotionDate = promotion.PromotionDate, PromotionType = promotion.PromotionType, Venue = promotion.Venue, Email = creator.Email, FirstName = creator.FirstName, LastName = creator.LastName, PhoneNumber = creator.LastName }; ViewBag.Costs = costs; ViewBag.PromotionTypes = promotionTypes; return(View(prom)); }
public ActionResult Create( PromotionVM promotion) { if (ModelState.IsValid) { //promotion creator: PromotionCreator creator = new PromotionCreator() { Email = promotion.Email, FirstName = promotion.FirstName, LastName = promotion.LastName, PhoneNumber = promotion.PhoneNumber }; db.PromotionCreators.Add(creator); db.SaveChanges(); Promotion model = new Promotion() { Cost = promotion.Cost, Description = promotion.Description, Duration = promotion.Duration.Value, PromotionDate = promotion.PromotionDate.Value, PromotionType = promotion.PromotionType, Venue = promotion.Venue, PromotionCreatorId = creator.Id }; db.Promotions.Add(model); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Costs = costs; ViewBag.PromotionTypes = promotionTypes; return(View(promotion)); }
public ActionResult DeleteConfirmed(int id) { PromotionCreator promotionCreator = db.PromotionCreators.Find(id); db.PromotionCreators.Remove(promotionCreator); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,FirstName,LastName,PhoneNumber,Email")] PromotionCreator promotionCreator) { if (ModelState.IsValid) { db.Entry(promotionCreator).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(promotionCreator)); }
public ActionResult Create([Bind(Include = "Id,FirstName,LastName,PhoneNumber,Email")] PromotionCreator promotionCreator) { if (ModelState.IsValid) { db.PromotionCreators.Add(promotionCreator); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(promotionCreator)); }
// GET: PromotionCreators/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PromotionCreator promotionCreator = db.PromotionCreators.Find(id); if (promotionCreator == null) { return(HttpNotFound()); } return(View(promotionCreator)); }