コード例 #1
0
        //[ValidateAntiForgeryToken]
        public IActionResult CreateContest(ContestViewModel model)
        {
            if (ModelState.IsValid)
            {
                var newContest = new Contest();
                newContest.Date = model.Date;
                newContest.Name = model.ContestName;
                newContest      = _contestRepository.Add(newContest);
                _contestRepository.Commit();

                return(RedirectToAction("Index", "Home", new { id = newContest.Id }));  //Redirect till tävlingen
            }

            return(View(model));
        }