コード例 #1
0
ファイル: PlayActions.cs プロジェクト: iliecristian/csharp
        public PlayActions(PlayVM viewModel)
        {
            this.viewModel = viewModel;

            viewModel.Timer       = new System.Windows.Threading.DispatcherTimer();
            viewModel.Timer.Tick += new EventHandler(Timer_Tick);
        }
コード例 #2
0
        //[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));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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));
        }