Beispiel #1
0
        private static void SaveResultToDb(List <MultiplicationResult> results)
        {
            using (var entitiesContext = new MathsQuizEntities())
            {
                entitiesContext.MultiplicationQuizResults.Add(new MultiplicationQuizResult
                {
                    Answered   = results.Count(),
                    Correct    = results.Count(r => r.IsCorrect),
                    QuizDate   = DateTime.Now,
                    QuizUser   = HttpContext.Current.User.Identity.Name,
                    TimesTable = GetMultiplesListing()
                });

                entitiesContext.SaveChanges();
            }
        }
Beispiel #2
0
        private static void SaveResultToDb(List <DecimalResult> results)
        {
            using (var entitiesContext = new MathsQuizEntities())
            {
                var decimalOperatorRange = (IEnumerable <DecimalOperator>)HttpContext.Current.Session[QuizDecimalOpertorRangeSessionKey];
                entitiesContext.DecimalQuizResults.Add(new DecimalQuizResult
                {
                    Answered     = results.Count(),
                    Correct      = results.Count(r => r.IsCorrect),
                    QuizDate     = DateTime.Now,
                    QuizUser     = HttpContext.Current.User.Identity.Name,
                    DecimalRange = string.Format("{0} - {1}", decimalOperatorRange.Min(), decimalOperatorRange.Max())
                });

                entitiesContext.SaveChanges();
            }
        }