Пример #1
0
        public Attempt AddAttemption(User user, Problem problem)
        {
            var t = new Attempt(user, problem);

            user.Attempts.Add(t);
            AppContext.Update(user);
            AppContext.Update(t);
            // AppContext.SaveChanges();
            return(t);
        }
Пример #2
0
        public bool TryAddStudent(string name, string lastName, DateTime birthday, int course, string login,
                                  string passwordHash)
        {
            if (AppContext.Students.Any(u => u.Login == login))
            {
                return(false);
            }
            Student student = new Student(name, lastName, birthday, course, login, passwordHash);

            AppContext.Students.Add(student);
            AppContext.SaveChangesAsync();
            return(true);
        }
Пример #3
0
        public bool RemoveUser(User user)
        {
            if (user == null)
            {
                return(false);
            }
            if (user.Role == Role.Student)
            {
                AppContext.Students.Remove(user as Student);
            }
            else if (user.Role == Role.Teacher)
            {
                AppContext.Teachers.Remove(user as Teacher);
            }

            AppContext.SaveChanges();
            return(true);
        }
Пример #4
0
 public void AddProblem(Teacher teacher, Problem problem)
 {
     teacher.MyProblems.Add(problem);
     AppContext.Update(teacher);
 }
Пример #5
0
 public void AddTeacher(string name, string lastName, DateTime birthday, string login, string passwordHash)
 {
     AppContext.Teachers.Add(new Teacher(name, lastName, birthday, login, passwordHash));
     AppContext.SaveChanges();
 }
Пример #6
0
 public Model()
 {
     AppContext = new AppContext();
 }