示例#1
0
        public async Task <ActionResult> SaveScore(int score)
        {
            var userId = User.Identity.GetUserId().ToString();

            if (score >= 0 && score <= 10)
            {
                TodayWord         word       = TempData["Word"] as TodayWord;
                IList <TodayWord> todayWords = TempData["ListWords"] as IList <TodayWord>;

                LectureViewModel model = new LectureViewModel(word, todayWords);
                // increase exp;
                await m_expService.AddExpForLearnWordAsync(userId, word.WordId, score, word.WordId); // comple word

                // save learnword result
                var result = m_learnWordService.SaveLearnWordResult(model.TodayWord, score);
                await m_expService.AddExpForContinuousLearningAsync(userId, todayWords); // continues if complete all words

                TempData["ListWordToDay"] = todayWords;
                // Update partial view
                if (result == ServiceResult.Success)
                {
                    return(PartialView("_ListTodayWordPartial", todayWords));
                }
            }

            return(Json("error", JsonRequestBehavior.AllowGet));
        }