public ActionResult Answer(IncludedIdioms included, string Question, int Page) { FlashCardListViewModel flashCardListViewModel = new FlashCardListViewModel(); flashCardListViewModel.Words = included.Words; flashCardListViewModel.PagingPrevNext = new PagingPrevNext { CurrentPage = Page, TotalItems = flashCardListViewModel.Words.Count() }; //Find Solution Word word = flashCardListViewModel.Words.ElementAt(Page - 1); string URL = ""; //TRANSPARENCY ON LINE https://www194.lunapic.com/editor/ if (Question == word.NumberPinyin) { Result = "Ok"; URL = "/IdiomsCardRandom/Index/" + "/" + (Page + 1).ToString() + "/Ok"; } else { Result = "Wrong"; URL = "/IdiomsCardRandom/Index/" + "/" + (Page + 1).ToString() + "/Ko"; } return(new RedirectResult(URL)); }
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { IncludedIdioms included = null; //SESSION if (controllerContext.HttpContext.Session != null) { included = (IncludedIdioms)controllerContext.HttpContext.Session[sessionKey]; } if (included == null) { included = new IncludedIdioms(); //TODO included.Words = ToList(LoadIncluded()); if (controllerContext.HttpContext.Session != null) { controllerContext.HttpContext.Session[sessionKey] = included; } } return(included); }
public ActionResult Index(IncludedIdioms includedIdioms, int Page = 1, string Result = "") { //Generate Words FlashCardListViewModel flashCardListViewModel = new FlashCardListViewModel(); flashCardListViewModel.Words = includedIdioms.Words; GenerateIdiomsAnswers(flashCardListViewModel, Page); //Select One for Show and Pagination flashCardListViewModel.Words = flashCardListViewModel.Words.OrderBy(w => w.Id).Skip((Page - 1)).Take(1); flashCardListViewModel.PagingPrevNext = new PagingPrevNext { CurrentPage = Page, TotalItems = flashCardListViewModel.Words.Count() }; ViewBag.Result = Result; return(View("Index", flashCardListViewModel)); }