Example #1
0
        public void GeeftLocatiesVoorGeselecteerdLandWeer()
        {
            string belgie = "Belgiƫ";
            string europa = "Europa";

            _graadMock = _graadMockFactory.MaakTweedeGraadEersteJaarAan();
            Leerling leerling = new Leerling {
                Graad = _graadMock.Object
            };
            var vmLand = new KlimatogramKiezenLandViewModel();

            vmLand.Land = belgie;
            var continent = _graadMock.Object.Continenten.First(c => c.Naam.Equals(europa));
            var result    = _klimatogramController.KiesLand(leerling, continent, vmLand) as PartialViewResult;
            var vmLocatie = result.Model as KlimatogramKiezenLocatieViewModel;

            CollectionAssert.AreEqual(continent.Landen.First(l => l.Naam.Equals(belgie)).Klimatogrammen.Select(k => k.Locatie).ToList(), vmLocatie.Locaties.Select(l => l.Text).ToList());
        }
Example #2
0
        public ActionResult KiesLand(Leerling leerling, Continent continent, KlimatogramKiezenLandViewModel kVM)
        {
            if (!ModelState.IsValid)
            {
                return(null);
            }
            Land land = continent.GeefLand(kVM.Land);

            if (land != null && (kVM.Land == null || !land.HeeftKlimatogrammen()))
            {
                TempData["Error"] = "Er zijn geen gegevens beschikbaar voor het geselecteerde land.";
                return(JavaScript("window.location = '" + Url.Action("Index") + "'"));
            }
            if (HttpContext != null && HttpContext.Session != null)
            {
                HttpContext.Session["land"] = land;
            }
            return(PartialView("_KiesLocatie", new KlimatogramKiezenLocatieViewModel(land.Klimatogrammen)));
        }