コード例 #1
0
ファイル: EventsController.cs プロジェクト: EtienneDG/Pronos
        public ActionResult Create(EventsModel model)
        {
            if (ModelState.IsValid)
            {
                var StartDate = Request["StartDate"];
                var EndDate = Request["EndDate"];

                var sprt = SelectAllSports().First(x => x.Id.ToString() == model.SelectedSport);
                var evt = new Events
                {
                    Name = model.Name,
                    Description = model.Description,
                    StartDate = model.StartDate,
                    EndDate = model.EndDate,
                    Sports = sprt
                };

                db.EventsSet.AddObject(evt);
                db.SaveChanges();
                var id = evt.Id;
                return RedirectToAction("Details", "Events", new {@id = id });
            }
            model.SportList = GetSportsList();
            return View(model);
        }
コード例 #2
0
ファイル: EventsController.cs プロジェクト: EtienneDG/Pronos
 //
 // GET: /Events/Create
 public ActionResult Create()
 {
     var Evtmodel = new EventsModel(); //Create instance of VM
     Evtmodel.SportList = GetSportsList();
     //var AvailableSports = db.SportsSet.ToList();
     //ViewBag.AvailableSports = AvailableSports;
     return View(Evtmodel);
 }