Exemplo n.º 1
0
 public bool SignIn(string login, string password)
 {
     Users user;
     using (var context = new QuizDBEntities())
     {
         user = context.Users
             .FirstOrDefault(c => c.user_login == login && c.user_pass == password);
     }
     if (user != null)
     {
         return true;
     }
     return false;
 }
Exemplo n.º 2
0
        public Test GetTest()
        {
            var test = new Test();
            using (var context = new QuizDBEntities())
            {
                var tests = context.Tests.ToArray();
                var questions = context.Questions.ToArray();
                var variants = context.Variants.ToArray();

                test = tests
                    .Select(t => new Test
                                     {
                                         Name = t.name,
                                         Questions = questions
                                                            .Where(q => q.testId == t.id)
                                                            .Select(q => new Question
                                                                             {
                                                                                 Id = q.id,
                                                                                 QuestionText = q.question,
                                                                                 Variants = variants
                                                                                 .Where(v => v.questionId == q.id)
                                                                                 .Select(v => new Variant
                                                                                 {
                                                                                     Id = v.id,
                                                                                     VariantText = v.variant,
                                                                                     ImageUri = v.imgPath,
                                                                                     Type = v.variant_type
                                                                                 })
                                                                                 .ToList()
                                                                             })
                                                            .ToList()
                                     })
                    .ToList()[1];
            }
            return test;
        }