Exemple #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();
             }
         }
     }
 }
Exemple #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();
         }
     }
 }
Exemple #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);
             }
         }
     }
 }
Exemple #4
0
        public Announcement GetAnnouncement(int id)
        {
            VCDataModelContainer data = new VCDataModelContainer();
            Announcement         a    = data.Announcements.Find(id);

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

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

            return(q);
        }
Exemple #7
0
 public void AddTeacher(Teacher teacher)
 {
     using (VCDataModelContainer data = new VCDataModelContainer())
     {
         data.Teachers.Add(teacher);
         data.SaveChanges();
     }
 }
Exemple #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();
     }
 }
Exemple #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();
     }
 }
Exemple #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();
     }
 }
Exemple #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();
     }
 }
Exemple #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();
     }
 }
Exemple #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);
     }
 }
Exemple #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);
     }
 }
Exemple #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);
     }
 }
Exemple #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();
     }
 }
Exemple #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();
     }
 }
Exemple #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();
         }
     }
 }
Exemple #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);
     }
 }
Exemple #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);
     }
 }
Exemple #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();
     }
 }
Exemple #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();
     }
 }
Exemple #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);
     }
 }
Exemple #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();
         }
     }
 }
Exemple #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);
                    }
                }
            }
        }
Exemple #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();
         }
     }
 }
Exemple #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);
     }
 }
Exemple #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);
        }
Exemple #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);
     }
 }
Exemple #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);
     }
 }