コード例 #1
0
 public void SavePIN(string username, string PIN)
 {
     using (VCDataModelContainer data = new VCDataModelContainer())
     {
         int count = (from x in data.Students
                      where x.Username.Equals(username)
                      select x).Count();
         if (count != 0)
         {
             data.Students.First(x => x.Username.Equals(username)).PasswordResetPIN = PIN;
             data.SaveChanges();
         }
         else
         {
             count = (from x in data.Teachers
                      where x.Username.Equals(username)
                      select x).Count();
             if (count != 0)
             {
                 data.Teachers.First(x => x.Username.Equals(username)).PasswordResetPIN = PIN;
                 data.SaveChanges();
             }
         }
     }
 }
コード例 #2
0
 public void AddUserDetails(string username, string Phone, string Website, bool EmailConfirmed)
 {
     using (VCDataModelContainer data = new VCDataModelContainer())
     {
         int count = (from x in data.Students
                      where x.Username.Equals(username)
                      select x).Count();
         if (count != 0)
         {
             Student s = data.Students.First(x => x.Username.Equals(username));
             s.Mobile         = Phone;
             s.Website        = Website;
             s.EmailConfirmed = EmailConfirmed;
             data.SaveChanges();
             return;
         }
         count = (from x in data.Teachers
                  where x.Username.Equals(username)
                  select x).Count();
         if (count != 0)
         {
             Teacher t = data.Teachers.First(x => x.Username.Equals(username));
             t.Mobile         = Phone;
             t.Website        = Website;
             t.EmailConfirmed = EmailConfirmed;
             data.SaveChanges();
         }
     }
 }
コード例 #3
0
 public string GetUserEmailConfirmationPIN(string username)
 {
     using (VCDataModelContainer data = new VCDataModelContainer())
     {
         int count = (from x in data.Students
                      where x.Username.Equals(username)
                      select x).Count();
         if (count != 0)
         {
             return(data.Students.First(x => x.Username.Equals(username)).EmailConfirmationPIN);
         }
         else
         {
             count = (from x in data.Teachers
                      where x.Username.Equals(username)
                      select x).Count();
             if (count != 0)
             {
                 return(data.Teachers.First(x => x.Username.Equals(username)).EmailConfirmationPIN);
             }
             else
             {
                 return(null);
             }
         }
     }
 }
コード例 #4
0
        public Announcement GetAnnouncement(int id)
        {
            VCDataModelContainer data = new VCDataModelContainer();
            Announcement         a    = data.Announcements.Find(id);

            return(a);
        }
コード例 #5
0
        public Assignment GetAssignment(int id)
        {
            VCDataModelContainer data = new VCDataModelContainer();
            Assignment           a    = data.Assignments.Find(id);

            return(a);
        }
コード例 #6
0
        public Quiz GetQuiz(int id)
        {
            VCDataModelContainer data = new VCDataModelContainer();
            Quiz q = data.Quizs.Find(id);

            return(q);
        }
コード例 #7
0
 public void AddTeacher(Teacher teacher)
 {
     using (VCDataModelContainer data = new VCDataModelContainer())
     {
         data.Teachers.Add(teacher);
         data.SaveChanges();
     }
 }
コード例 #8
0
 public void ChangePassword(int sId, string Password)
 {
     using (VCDataModelContainer data = new VCDataModelContainer())
     {
         Student s = data.Students.Find(sId);
         s.Password = Password;
         data.SaveChanges();
     }
 }
コード例 #9
0
 public void SaveDiscussion(int cid, Discussion discussion)
 {
     using (VCDataModelContainer data = new VCDataModelContainer())
     {
         Course c = data.Courses.Find(cid);
         c.Discussions.Add(discussion);
         data.SaveChanges();
     }
 }
コード例 #10
0
 public void AddComment(int did, DiscussionComment comment)
 {
     using (VCDataModelContainer data = new VCDataModelContainer())
     {
         Discussion d = data.Discussions.Find(did);
         d.Comments.Add(comment);
         data.SaveChanges();
     }
 }
コード例 #11
0
 public void MakeAnnouncement(int cid, Announcement announcement)
 {
     using (VCDataModelContainer data = new VCDataModelContainer())
     {
         Course c = data.Courses.Find(cid);
         c.Announcements.Add(announcement);
         data.SaveChanges();
     }
 }
コード例 #12
0
 public void ChangePassword(int tId, string Password)
 {
     using (VCDataModelContainer data = new VCDataModelContainer())
     {
         Teacher t = data.Teachers.Find(tId);
         t.Password = Password;
         data.SaveChanges();
     }
 }
コード例 #13
0
 public bool DoesStudentEmailExist(string Email)
 {
     using (VCDataModelContainer data = new VCDataModelContainer())
     {
         int count = (from x in data.Students
                      where x.Email.Equals(Email)
                      select x).Count();
         return(count != 0);
     }
 }
コード例 #14
0
 public bool IsTeacherEmail(string Email)
 {
     using (VCDataModelContainer data = new VCDataModelContainer())
     {
         int count = (from x in data.Teachers
                      where x.Email.Equals(Email)
                      select x).Count();
         return(count != 0);
     }
 }
コード例 #15
0
 public bool DoesSolutionExist(int quizId, int studentId)
 {
     using (VCDataModelContainer data = new VCDataModelContainer())
     {
         int count = (from x in data.QuizSolutions
                      where x.StudentId == studentId && x.QuizId == quizId
                      select x).Count();
         return(count != 0);
     }
 }
コード例 #16
0
 public void AddStudentByEmail(string Email)
 {
     using (VCDataModelContainer data = new VCDataModelContainer())
     {
         Student s = new Student {
             Email = Email, EmailConfirmed = false
         };
         data.Students.Add(s);
         data.SaveChanges();
     }
 }
コード例 #17
0
 public void AddCourse(string username, string title)
 {
     using (VCDataModelContainer data = new VCDataModelContainer())
     {
         Course c = new Course();
         c.Title  = title;
         c.Active = true;
         data.Teachers.First(x => x.Username.Equals(username)).Courses.Add(c);
         data.SaveChanges();
     }
 }
コード例 #18
0
 public void SetActive(int id, bool active)
 {
     using (VCDataModelContainer data = new VCDataModelContainer())
     {
         Course c = data.Courses.Find(id);
         if (c != null)
         {
             c.Active = active;
             data.SaveChanges();
         }
     }
 }
コード例 #19
0
 public Teacher GetInstructor(int cid)
 {
     using (VCDataModelContainer data = new VCDataModelContainer())
     {
         Course c = data.Courses.Find(cid);
         if (c == null)
         {
             return(null);
         }
         return(c.Teacher);
     }
 }
コード例 #20
0
 public string GetEmailConfirmationPIN(string Email)
 {
     using (VCDataModelContainer data = new VCDataModelContainer())
     {
         int count = (from x in data.Students
                      where x.Email.Equals(Email)
                      select x).Count();
         if (count != 0)
         {
             return(data.Students.First(x => x.Email.Equals(Email)).EmailConfirmationPIN);
         }
         return(null);
     }
 }
コード例 #21
0
 public void AddAssignment(Course course, Assignment assignment, List <AssignmentQuestion> questions)
 {
     using (VCDataModelContainer data = new VCDataModelContainer())
     {
         Course c = data.Courses.Find(course.Id);
         c.Assignments.Add(assignment);
         data.SaveChanges();
         foreach (AssignmentQuestion q in questions)
         {
             assignment.Questions.Add(q);
         }
         data.SaveChanges();
     }
 }
コード例 #22
0
 public void AddQiuz(Course course, Quiz quiz, List <QuizQuestion> questions)
 {
     using (VCDataModelContainer data = new VCDataModelContainer())
     {
         Course c = data.Courses.Find(course.Id);
         c.Quizzes.Add(quiz);
         data.SaveChanges();
         foreach (QuizQuestion q in questions)
         {
             quiz.Questions.Add(q);
         }
         data.SaveChanges();
     }
 }
コード例 #23
0
 public bool DoesStudentEmailConfirmed(string Email)
 {
     using (VCDataModelContainer data = new VCDataModelContainer())
     {
         int count = (from x in data.Students
                      where x.Email.Equals(Email)
                      select x).Count();
         if (count != 0)
         {
             return(data.Students.First(x => x.Email.Equals(Email)).EmailConfirmed);
         }
         return(false);
     }
 }
コード例 #24
0
 public void SaveEmailConfirmationPIN(string Email, string PIN)
 {
     using (VCDataModelContainer data = new VCDataModelContainer())
     {
         int count = (from x in data.Students
                      where x.Email.Equals(Email)
                      select x).Count();
         if (count != 0)
         {
             data.Students.First(x => x.Email.Equals(Email)).EmailConfirmationPIN = PIN;
             data.SaveChanges();
         }
     }
 }
コード例 #25
0
        public int CheckLoginDetails(LoginDetails log)
        {
            using (VCDataModelContainer data = new VCDataModelContainer())
            {
                Teacher t = null;
                try
                {
                    t = data.Teachers.First(x => x.Username.Equals(log.Username));
                }
                catch (InvalidOperationException) { }

                if (t != null)
                {
                    if (t.Password.Equals(log.Password))
                    {
                        return(1);
                    }
                    else
                    {
                        return(0);
                    }
                }
                else
                {
                    Student s = null;
                    try
                    {
                        s = data.Students.First(x => x.Username.Equals(log.Username));
                    }
                    catch (InvalidOperationException) { }

                    if (s != null)
                    {
                        if (s.Password.Equals(log.Password))
                        {
                            return(2);
                        }
                        else
                        {
                            return(0);
                        }
                    }
                    else
                    {
                        return(0);
                    }
                }
            }
        }
コード例 #26
0
 public void EnrollStudent(string Email, int cid)
 {
     using (VCDataModelContainer data = new VCDataModelContainer())
     {
         Course c     = data.Courses.Find(cid);
         int    count = (from x in c.Students
                         where x.Email.Equals(Email)
                         select x).Count();
         if (count == 0)
         {
             c.Students.Add(data.Students.First(x => x.Email.Equals(Email)));
             data.SaveChanges();
         }
     }
 }
コード例 #27
0
 public bool DoesStudentEnrolledInCourse(string username, int cid)
 {
     using (VCDataModelContainer data = new VCDataModelContainer())
     {
         Course c = data.Courses.Find(cid);
         if (c == null)
         {
             return(false);
         }
         int count = (from x in c.Students
                      where x.Username != null && x.Username.Equals(username)
                      select x).Count();
         return(count != 0);
     }
 }
コード例 #28
0
        public QuizSolution GetQuizSolution(int qId, int sId)
        {
            VCDataModelContainer data = new VCDataModelContainer();
            int count = (from x in data.QuizSolutions
                         where x.StudentId == sId && x.QuizId == qId
                         select x).Count();

            if (count != 0)
            {
                QuizSolution qs = (from x in data.QuizSolutions
                                   where x.StudentId == sId && x.QuizId == qId
                                   select x).First();
                return(qs);
            }
            return(null);
        }
コード例 #29
0
 public bool DoesUsernameExist(string username)
 {
     using (VCDataModelContainer data = new VCDataModelContainer())
     {
         int count = (from x in data.Students
                      where x.Username.Equals(username)
                      select x).Count();
         if (count != 0)
         {
             return(true);
         }
         count = (from x in data.Teachers
                  where x.Username.Equals(username)
                  select x).Count();
         return(count != 0);
     }
 }
コード例 #30
0
 public bool DoesEmailExist(string email)
 {
     using (VCDataModelContainer data = new VCDataModelContainer())
     {
         int count = (from x in data.Teachers
                      where x.Email.Equals(email)
                      select x).Count();
         if (count != 0)
         {
             return(true);
         }
         count = (from x in data.Students
                  where x.Email.Equals(email)
                  select x).Count();
         return(count != 0);
     }
 }