예제 #1
0
        public IActionResult AddHallConfirmed(SportHallenViewModel viewModel)
        {
            ViewBag.Title = "Sporthallen toevoegen";

            if (ModelState.ContainsKey("Hall.HallId") && ModelState.ContainsKey("Hall.SportComplex"))
            {
                ModelState["Hall.HallId"].ValidationState       = ModelValidationState.Valid;
                ModelState["Hall.SportComplex"].ValidationState = ModelValidationState.Valid;
            }

            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            var hall    = viewModel.Hall;
            var complex = _complexAccess.GetSportComplex(viewModel.SportComplexId);

            hall.SportComplex = complex;

            _complexAccess.AddHall(viewModel.Hall);

            viewModel.SportHalls = _complexAccess.GetHalls(viewModel.SportComplexId);

            return(RedirectToAction("Hall", viewModel));
        }