public void InsertQuestion(QuestionBank question) { using (_context = new ExaminationContext()) { _context.QuestionBank.Add(question); //_context.Entry(question).State = EntityState.Added; _context.SaveChanges(); } }
public void InsertUser(SystemUser user) { using (_context = new ExaminationContext()) { _context.SystemUser.Add(user); //_context.Entry(user).State = EntityState.Added; _context.SaveChanges(); } }
public void SendExamToArchieve(int examId, bool toArchive) { using (_context = new ExaminationContext()) { _context.Exam.Where(e => e.ExamId == examId).Single().Archived = toArchive; _context.SaveChanges(); } }
public void InsertSubject(Subject subject) { using (_context = new ExaminationContext()) { _context.Subject.Add(subject); //_context.Entry(subject).State = EntityState.Added; _context.SaveChanges(); } }
public void UpdateSubject(Subject subject) { using (_context = new ExaminationContext()) { _context.Entry(subject).State = EntityState.Modified; _context.SaveChanges(); } }
public void IncreaseExamineeExamTaken(int examineeId) { using (_context = new ExaminationContext()) { Examinee examinee = _context.Examinee.Find(examineeId); examinee.ExamTakes += 1; _context.SaveChanges(); } }
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(); } }
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(); } }
public void InsertExam(Exam exam) { using (_context = new ExaminationContext()) { exam.DateTimeAdded = GetServerDateTime(_context); _context.Exam.Add(exam); _context.SaveChanges(); } }
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(); } }
public void SetPassingRate(PassingRate passingRate) { using (_context = new ExaminationContext()) { passingRate.DateTimeModified = GetServerDateTime(_context); _context.PassingRate.Add(passingRate); _context.SaveChanges(); } }
public void SetWaitDays(ExamineeFailure examineeFailure) { using (_context = new ExaminationContext()) { examineeFailure.DateTimeModified = GetServerDateTime(_context); _context.ExamineeFailure.Add(examineeFailure); _context.SaveChanges(); } }
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(); } }
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(); } }
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(); } }
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); }
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(); } }
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(); } }
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); }