public PlayActions(PlayVM viewModel) { this.viewModel = viewModel; viewModel.Timer = new System.Windows.Threading.DispatcherTimer(); viewModel.Timer.Tick += new EventHandler(Timer_Tick); }
//[HttpPost] public ActionResult EditChildEntity(PlayVM model) { QuotesRepository qRepo = new QuotesRepository(); Quote quote = qRepo.GetById(model.quote.Id, "Author"); model.UserQuotesEditVM.Score = CheckAnswer(model.UserQuotesEditVM.SelectedAnswer, quote.Author.Name, model.authors[0].Name); bool result = model.UserQuotesEditVM.Score; model.msg = GenerateMsg(result, quote.Author.Name); model.quote.Text = quote.Text; KeepTrackOfPlayedGames(quote); if (AuthenticationManager.LoggedUser != null) { SaveUserQuote(model, quote); } return(View("Play", model)); }
public ActionResult Play(PlayVM model) { if (Session["GameMode"] == null) { Session["GameMode"] = "Binary"; } model.quote = ChooseQuote(); if (model.quote == null) { return(View("TheEnd")); } model.msg = ""; model.authors = PopulateAuthorList(model.authors, model.quote); model.quote.Author = null; return(View(model)); }
private void SaveUserQuote(PlayVM model, Quote quote) { UserQuotesRepository uqRepo = new UserQuotesRepository(); UserQuote item = new UserQuote(); model.UserQuotesEditVM.UserId = AuthenticationManager.LoggedUser.Id; model.UserQuotesEditVM.QuoteId = quote.Id; model.UserQuotesEditVM.CorrectAuthorName = quote.Author.Name; if (model.UserQuotesEditVM.SelectedAnswer == "No" || model.UserQuotesEditVM.SelectedAnswer == "Yes") { model.UserQuotesEditVM.ShownAnswer = model.authors[0].Name; } else { model.UserQuotesEditVM.ShownAnswer = "Options"; } model.UserQuotesEditVM.PopulateEntity(item); uqRepo.Save(item); }
public void SaveTutorContext(HttpContext context, InputLangOption langOption, PlayVM playVM) { var sessionKey = context.User.Identity.Name + sessionKeyEnd; ISession session = context.Session; var tutorSession = new TutorSessionModel { LangOption = langOption, Word = playVM.Word, Translation = playVM.Translation, }; session.SetString(sessionKey, JsonConvert.SerializeObject(tutorSession)); }