private SelectListItem GetEventItem(AdareShow s) { string dt = DateFormat.GetDateString(s.EventDate); return new SelectListItem { Value = s.Id.ToString(), Text = string.Format(_descriptionformat, s.ShowType.Description, dt), }; }
public ActionResult Edit(AdareShow adareshow) { if (ModelState.IsValid) { db.Entry(adareshow).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.EventTypeId = new SelectList(db.EventTypes, "Id", "Description", adareshow.EventTypeId); return View(adareshow); }
public ActionResult Create(AdareShow adareshow) { try { if (ModelState.IsValid) { db.AdareShows.Add(adareshow); db.SaveChanges(); return RedirectToAction("Index"); } } catch (Exception) { ModelState.AddModelError(string.Empty, "Please select a proper event date."); } ViewBag.EventTypeId = new SelectList(db.EventTypes, "Id", "Description", adareshow.EventTypeId); return View(adareshow); }