Esempio n. 1
0
        public ActionResult SpellTest(FormCollection collection, SpellingBeeSelectionViewModel spellingBeeModel) //int numOfWordsId, bool topWrongs)
        {
            try
            {
                var appUser = SpellUserManager.FindByName(User.Identity.Name);

                if (ModelState.IsValid && spellingBeeModel != null)
                {
                    var selectedBeeId = spellingBeeModel.SpellingBeeList.SelectedSpellingBee;
                    var words = _repository.GetWordsForTest(selectedBeeId);

                    var model = new TestViewModel();
                    model.SpellingBeeTestId = spellingBeeModel.SpellingBeeList.SelectedSpellingBee; 
                    model.ShowSwedish = spellingBeeModel.ShowSwedish;
                    var audioOn = spellingBeeModel.AudioOn;
                    model.Words = words.Select(m =>
                        new WordViewModel
                        {
                            EnglishText = m.EnglishText,
                            SwedishText = m.SwedishText,
                            WordId = m.WordId
                        }).ToList();
                    return View(model);
                }
            }
            catch (Exception e)
            {
                log.Error("Något gick fel.", e);
            }

            return RedirectToAction("Index");
        }
Esempio n. 2
0
        // GET: Spell
        public ActionResult Index()
        {
            try
            {
                log.Debug("Nuskavise.");
                var bees = _repository.GetSpellingBeeTests();
                var typeList = new List<SelectListItem>();

                foreach (var test in bees)
                {
                    typeList.Add(new SelectListItem
                        {
                            Text = test.Name,
                            Value = test.SpellingBeeTestId.ToString()
                        });
                }
                var types = new SelectList(typeList, "Value", "Text");
                var selection = new SpellingBeeSelection()
                {
                    SpellingBees = types
                };

                var model = new SpellingBeeSelectionViewModel() { SpellingBeeList = selection, AudioOn = true, ShowSwedish = true };

                return View(model);
            }
            catch (Exception e)
            {
                log.Error("Något gick fel.", e);
            }
            return View();
        }