コード例 #1
0
 public void InsertQuestion(QuestionBank question)
 {
     using (_context = new ExaminationContext())
     {
         _context.QuestionBank.Add(question); //_context.Entry(question).State = EntityState.Added;
         _context.SaveChanges();
     }
 }
コード例 #2
0
 public void InsertUser(SystemUser user)
 {
     using (_context = new ExaminationContext())
     {
         _context.SystemUser.Add(user); //_context.Entry(user).State = EntityState.Added;
         _context.SaveChanges();
     }
 }
コード例 #3
0
 public void SendExamToArchieve(int examId, bool toArchive)
 {
     using (_context = new ExaminationContext())
     {
         _context.Exam.Where(e => e.ExamId == examId).Single().Archived = toArchive;
         _context.SaveChanges();
     }
 }
コード例 #4
0
 public void InsertSubject(Subject subject)
 {
     using (_context = new ExaminationContext())
     {
         _context.Subject.Add(subject); //_context.Entry(subject).State = EntityState.Added;
         _context.SaveChanges();
     }
 }
コード例 #5
0
 public void UpdateSubject(Subject subject)
 {
     using (_context = new ExaminationContext())
     {
         _context.Entry(subject).State = EntityState.Modified;
         _context.SaveChanges();
     }
 }
コード例 #6
0
 public void IncreaseExamineeExamTaken(int examineeId)
 {
     using (_context = new ExaminationContext())
     {
         Examinee examinee = _context.Examinee.Find(examineeId);
         examinee.ExamTakes += 1;
         _context.SaveChanges();
     }
 }
コード例 #7
0
 public void UpdateExaminee(Examinee examinee)
 {
     using (_context = new ExaminationContext())
     {
         _context.Entry(examinee).State = EntityState.Modified;
         //_context.Entry(examinee).Property(p => p.DateTimeAdded).IsModified = false; //  DateTimeAdded should not be modified
         _context.SaveChanges();
     }
 }
コード例 #8
0
 public void InsertExaminee(Examinee examinee)
 {
     using (_context = new ExaminationContext())
     {
         examinee.DateTimeAdded = GetServerDateTime(_context);
         _context.Examinee.Add(examinee); //_context.Entry(examinee).State = EntityState.Added;
         _context.SaveChanges();
     }
 }
コード例 #9
0
 public void InsertExam(Exam exam)
 {
     using (_context = new ExaminationContext())
     {
         exam.DateTimeAdded = GetServerDateTime(_context);
         _context.Exam.Add(exam);
         _context.SaveChanges();
     }
 }
コード例 #10
0
 public void UpdateUser(SystemUser user)
 {
     using (_context = new ExaminationContext())
     {
         _context.Entry(user).State = EntityState.Modified;
         _context.Entry(user).Property(u => u.Pword).IsModified = false;
         _context.SaveChanges();
     }
 }
コード例 #11
0
 public void SetPassingRate(PassingRate passingRate)
 {
     using (_context = new ExaminationContext())
     {
         passingRate.DateTimeModified = GetServerDateTime(_context);
         _context.PassingRate.Add(passingRate);
         _context.SaveChanges();
     }
 }
コード例 #12
0
 public void SetWaitDays(ExamineeFailure examineeFailure)
 {
     using (_context = new ExaminationContext())
     {
         examineeFailure.DateTimeModified = GetServerDateTime(_context);
         _context.ExamineeFailure.Add(examineeFailure);
         _context.SaveChanges();
     }
 }
コード例 #13
0
 public void DeleteSubject(int subjectId)
 {
     using (_context = new ExaminationContext())
     {
         //Subject subject = new Subject { SubjectId = subjectId };
         //_context.Entry(subject).State = EntityState.Deleted;
         _context.Subject.Remove(_context.Subject.Single(s => s.SubjectId == subjectId));
         _context.SaveChanges();
     }
 }
コード例 #14
0
 public void DeleteExam(int examId)
 {
     using (_context = new ExaminationContext())
     {
         //Examinee examinee = new Examinee { ExamineeId = examineeId };
         //_context.Entry(examinee).State = EntityState.Deleted;
         _context.Exam.Remove(_context.Exam.SingleOrDefault(e => e.ExamId == examId));
         _context.SaveChanges();
     }
 }
コード例 #15
0
 public void UpdateOne(ExamineeTake examineeTake)
 {
     using (_context = new ExaminationContext())
     {
         //examineeTake.ExamDateTimeTaken = DateTime.Now.Date;
         _context.ExamineeExam.AddRange(examineeTake.ExamineeExam);
         //_context.ExamineeTake.Attach(examineeTake);
         _context.Entry(examineeTake).State = EntityState.Modified;
         _context.SaveChanges();
     }
 }
コード例 #16
0
        public string InsertExamineeTake(ExamineeTake examineeTake)
        {
            using (_context = new ExaminationContext())
            {
                examineeTake.CodeDateTimeIssued = GetServerDateTime(_context);
                examineeTake.UserId             = UserInfo.UserId;
                _context.ExamineeTake.Add(examineeTake);
                _context.SaveChanges();
            }

            return(examineeTake.ExamCode);
        }
コード例 #17
0
        public void UpdateExamineeTake(ExamineeTake examineeTake)
        {
            using (_context = new ExaminationContext())
            {
                //_context.ExamineeTake.Attach(examineeTake);
                //_context.ExamineeAnswer.AddRange(examineeTake.ExamineeExam.(s => s.ExamineeAnswer));

                //_context.Entry(examineeTake).State = EntityState.Modified;
                _context.ExamineeExam.AddRange(examineeTake.ExamineeExam);
                _context.Entry(examineeTake).State = EntityState.Modified;
                _context.SaveChanges();
            }
        }
コード例 #18
0
        public void UpdateQuestion(QuestionBank question)
        {
            using (_context = new ExaminationContext())
            {
                QuestionBankHistory questionHistory = new QuestionBankHistory();
                questionHistory.QuestionId       = question.QuestionId;
                questionHistory.QuestionNumber   = question.QuestionNumber;
                questionHistory.Question         = question.Question;
                questionHistory.CorrectAnswer    = question.CorrectAnswer;
                questionHistory.WrongAnswer1     = question.WrongAnswer1;
                questionHistory.WrongAnswer2     = question.WrongAnswer2;
                questionHistory.WrongAnswer3     = question.WrongAnswer3;
                questionHistory.UserId           = UserInfo.UserId;
                questionHistory.DateTimeModified = GetServerDateTime(_context);

                _context.Entry(question).State = EntityState.Modified;
                _context.QuestionBankHistory.Add(questionHistory);
                _context.SaveChanges();
            }
        }
コード例 #19
0
        public bool ChangePassword(LoginViewModel loginUser)
        {
            using (_context = new ExaminationContext())
            {
                SystemUser user = _context.SystemUser.Where(u => u.UserId == loginUser.UserId &&
                                                            u.Pword == loginUser.Password)
                                  .SingleOrDefault();

                if (user != null)
                {
                    user.Pword = loginUser.NewPassword;
                    _context.Entry(user).State = EntityState.Modified;
                    _context.SaveChanges();
                }
                else
                {
                    return(false);
                }
            }

            return(true);
        }