예제 #1
0
 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),
     };
 }
예제 #2
0
 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);
 }
예제 #3
0
        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);
        }