public Exam GetExam(int id)
 {
     using (var context = new OnlineTestContext(_dbContextOptionBuilder.Options))
     {
         return(context.Exams.FirstOrDefault(e => e.Id == id));
     }
 }
Beispiel #2
0
 public User Get(string email, string password)
 {
     using (var context = new OnlineTestContext(_dbContextOptionBuilder.Options))
     {
         return(context.Users.FirstOrDefault(u => u.Email.Equals(email) && u.Password.Equals(password)));
     }
 }
Beispiel #3
0
 public User Get(int Id)
 {
     using (var context = new OnlineTestContext(_dbContextOptionBuilder.Options))
     {
         return(context.Users.FirstOrDefault(u => u.Id == Id));
     }
 }
 public List <Exam> GetExams()
 {
     using (var context = new OnlineTestContext(_dbContextOptionBuilder.Options))
     {
         return(context.Exams.OrderByDescending(e => e.CreatedOn).ToList());
     }
 }
        public List <AnswerDetails> GetAnswerDetailsByExaminee(int examId, int examineeId)
        {
            using (var context = new OnlineTestContext(_dbContextOptionBuilder.Options))
            {
                var result = (from exam in context.Exams
                              join qus in context.Questions
                              on exam.Id equals qus.ExamId
                              join answer in context.Answers
                              on qus.Id equals answer.QuestionId
                              join examinee in context.Examinees
                              on answer.ExamineeId equals examinee.Id
                              where exam.Id == examId && answer.ExamineeId == examineeId
                              select new AnswerDetails
                {
                    ExamId = exam.Id,
                    ExamineeId = answer.ExamineeId,
                    AnswerId = answer.Id,
                    QuestionId = qus.Id,
                    Text = qus.Text,
                    SubText = qus.SubText,
                    Point = qus.Point,
                    TypeId = qus.TypeId,
                    AnswerText = answer.Text,
                    AnswerPoint = answer.Point,
                    ExamineeName = examinee.Name,
                    ExamineeEmail = examinee.Email,
                    ExamineePhone = examinee.Phone,
                    Title = exam.Title,
                    Duration = exam.Duration,
                    AssessedBy = answer.AssessedBy ?? ""
                }).OrderBy(a => a.QuestionId).ToList();

                return(result);
            }
        }
 public List <Question> GetByExam(int examId)
 {
     using (var context = new OnlineTestContext(_dbContextOptionBuilder.Options))
     {
         return(context.Questions.Where(q => q.ExamId == examId).ToList());
     }
 }
 public Exam GetExamByCode(string code)
 {
     using (var context = new OnlineTestContext(_dbContextOptionBuilder.Options))
     {
         return(context.Exams.FirstOrDefault(e => e.ExameCode.Equals(code)));
     }
 }
 public Examinee GetExamineeByExamAndEmail(int examId, string email)
 {
     using (var context = new OnlineTestContext(_dbContextOptionBuilder.Options))
     {
         return(context.Examinees.FirstOrDefault(e => e.Email.Equals(email) && e.ExamId == examId));
     }
 }
 public ExamStatu GetExamStatus(int examId, int examineeId)
 {
     using (var context = new OnlineTestContext(_dbContextOptionBuilder.Options))
     {
         return(context.ExamStatus.FirstOrDefault(e => e.ExamId == examId && e.ExamineeId == examineeId));
     }
 }
Beispiel #10
0
 public T Edit <T>(T entity) where T : class
 {
     using (var context = new OnlineTestContext(_dbContextOptionBuilder.Options))
     {
         context.Entry(entity).State = EntityState.Modified;
         context.SaveChanges();
         return(entity);
     }
 }
Beispiel #11
0
 public T Get <T>(int id) where T : class
 {
     using (var context = new OnlineTestContext(_dbContextOptionBuilder.Options))
     {
         DbSet <T> dbSet  = context.Set <T>();
         var       entity = dbSet.Find(id);
         return(entity);
     }
 }
Beispiel #12
0
 public List <T> GetAll <T>() where T : class
 {
     using (var context = new OnlineTestContext(_dbContextOptionBuilder.Options))
     {
         DbSet <T> dbSet      = context.Set <T>();
         var       entityList = dbSet.AsNoTracking().ToList();
         return(entityList);
     }
 }
Beispiel #13
0
 public T Delete <T>(T entity) where T : class
 {
     using (var context = new OnlineTestContext(_dbContextOptionBuilder.Options))
     {
         DbSet <T> dbSet = context.Set <T>();
         dbSet.Remove(entity);
         context.SaveChanges();
         return(entity);
     }
 }
Beispiel #14
0
 public bool EditAll <T>(List <T> entityList) where T : class
 {
     using (var context = new OnlineTestContext(_dbContextOptionBuilder.Options))
     {
         try
         {
             foreach (var entity in entityList)
             {
                 context.Entry(entity).State = EntityState.Modified;
             }
             context.SaveChanges();
             return(true);
         }
         catch (Exception ex)
         {
             return(false);
         }
     }
 }
Beispiel #15
0
 public bool AddAll <T>(List <T> entityList) where T : class
 {
     using (var context = new OnlineTestContext(_dbContextOptionBuilder.Options))
     {
         try
         {
             DbSet <T> dbSet = context.Set <T>();
             foreach (var entity in entityList)
             {
                 dbSet.Add(entity);
             }
             context.SaveChanges();
             return(true);
         }
         catch (Exception ex)
         {
             return(false);
         }
     }
 }
        public List <ExamineeDetails> GetExamStatus(int examId)
        {
            using (var context = new OnlineTestContext(_dbContextOptionBuilder.Options))
            {
                var submittedsQuestions = context.Answers.Where(a => a.ExamId == examId)
                                          .GroupBy(a => a.ExamineeId)
                                          .Select(a => new { ExamineeId = a.Key, Total = a.Select(x => x.QuestionId).Distinct().Count() });

                var result = (from exam in context.Exams
                              join stat in context.ExamStatus
                              on exam.Id equals stat.ExamId
                              join examinee in context.Examinees
                              on stat.ExamineeId equals examinee.Id
                              where exam.Id == examId
                              select new ExamineeDetails
                {
                    ExamId = exam.Id,
                    ExamineeId = examinee.Id,
                    ExamStatusId = stat.Id,
                    Title = exam.Title,
                    Name = examinee.Name,
                    Phone = examinee.Phone,
                    Email = examinee.Email,
                    Status = stat.Status,
                    TotalMarks = stat.TotalMarks,
                    ObtainedMarks = stat.ObtainedMarks
                }).OrderByDescending(t => t.Status)
                             .ThenByDescending(t => t.ObtainedMarks).ToList();

                foreach (var res in result)
                {
                    var item = submittedsQuestions.FirstOrDefault(s => s.ExamineeId == res.ExamineeId);
                    res.TotalSubmission = item?.Total ?? 0;
                }

                return(result);
            }
        }
 public ScoreRepository(OnlineTestContext dbContext)
 {
     DbContext = dbContext;
 }
Beispiel #18
0
 public MyService()
 {
     DbContext = new OnlineTestContext();
 }
Beispiel #19
0
 public BankRepository(OnlineTestContext _context)
 {
     DbContext = _context;
 }
 public UserRepository(OnlineTestContext dbContext)
 {
     DbContext = dbContext;
 }
 public QuestionRepository(OnlineTestContext _context)
 {
     DbContext = _context;
 }
Beispiel #22
0
 public ExamRepository(OnlineTestContext dbContext)
 {
     DbContext = dbContext;
 }
 public AnswerRepository(OnlineTestContext _DbContext)
 {
     DbContext = _DbContext;
 }