public ActionResult Traning() { List <Words> word = Session["WordQuestions"] as List <Words>; if (word != null) { ViewBag.ErrorLearn = string.Format("Вы выбрали {0} слов", word.Count); return(View()); } else { DropDowmModel dropDowmModel = new DropDowmModel(); List <SelectListItem> listItems = new List <SelectListItem>(); listItems.Add(new SelectListItem() { Value = "5", Text = "5 слов" }); listItems.Add(new SelectListItem() { Value = "10", Text = "10 слов" }); listItems.Add(new SelectListItem() { Value = "15", Text = "15 слов" }); ViewBag.DropDownValues = new SelectList(listItems, "Text", "Value"); ViewBag.ErrorLearn = "Выберите минимум 5 слов в наборах слов"; dropDowmModel.CountWord = listItems; return(View(dropDowmModel)); } }
public ActionResult ShowWords(DropDowmModel drop) { Random rand = new Random(); List <Words> words = Session["WordQuestions"] as List <Words>; if (words == null) { words = new List <Words>(); for (int i = 0; i < drop.Id; i++) { int id = rand.Next(1, 220); words.Add(db.Words.FirstOrDefault(s => s.Id == id)); } } return(View("ChoiceWord", words)); }