Exemple #1
0
        public ActionResult Create([Bind(Include = "EventTypeId,Type")] EventType eventType)
        {
            if (ModelState.IsValid)
            {
                db.EventTypes.Add(eventType);
                db.SaveChanges();
                return(RedirectToAction("Create", "Event"));
            }

            return(View(eventType));
        }
        public ActionResult Create([Bind(Include = "EventId,EventTypeId,Title,Description,StartDate,EndDate,City,State,OrganizationName,OrganizationContactInfo,MaxTickets,AvailableTickets")] Event @event)
        {
            if (@event.StartDate < DateTime.Now)
            {
                ModelState.AddModelError("StartDate", "Start Date can not be in the past.");
            }

            if (ModelState.IsValid)
            {
                db.Events.Add(@event);
                db.SaveChanges();
                return(RedirectToAction("Details"));
            }

            ViewBag.EventTypeId = new SelectList(db.EventTypes, "EventTypeId", "Type", @event.EventTypeId);
            return(View(@event));
        }