Example #1
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();
         }
     }
 }
Example #2
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();
             }
         }
     }
 }
Example #3
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();
     }
 }
Example #4
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();
     }
 }
Example #5
0
 public void AddTeacher(Teacher teacher)
 {
     using (VCDataModelContainer data = new VCDataModelContainer())
     {
         data.Teachers.Add(teacher);
         data.SaveChanges();
     }
 }
Example #6
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();
     }
 }
Example #7
0
 public void ChangePassword(int sId, string Password)
 {
     using (VCDataModelContainer data = new VCDataModelContainer())
     {
         Student s = data.Students.Find(sId);
         s.Password = Password;
         data.SaveChanges();
     }
 }
Example #8
0
 public void ChangePassword(int tId, string Password)
 {
     using (VCDataModelContainer data = new VCDataModelContainer())
     {
         Teacher t = data.Teachers.Find(tId);
         t.Password = Password;
         data.SaveChanges();
     }
 }
Example #9
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();
     }
 }
Example #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();
     }
 }
Example #11
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();
     }
 }
Example #12
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();
     }
 }
Example #13
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();
         }
     }
 }
Example #14
0
 public void ChangePassword(string username, string Password)
 {
     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)).Password = Password;
             data.SaveChanges();
             return;
         }
         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)).Password = Password;
             data.SaveChanges();
         }
     }
 }
Example #15
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();
         }
     }
 }
Example #16
0
 public void SaveQuizSolution(int quizId, int studentId, List <QuizQuestionSolution> solutions)
 {
     if (!DoesSolutionExist(quizId, studentId))
     {
         using (VCDataModelContainer data = new VCDataModelContainer())
         {
             int correct = 0, attempted = 0, marks = 0;
             for (int i = 0; i < solutions.Count; i++)
             {
                 QuizQuestion ques = data.QuizQuestions.Find(solutions[i].QuizQuestionId);
                 if (solutions[i].SelectedOption != 0)
                 {
                     attempted++;
                 }
                 solutions[i].IsCorrect = (ques.CorrectOption == solutions[i].SelectedOption);
                 if (solutions[i].IsCorrect)
                 {
                     correct++;
                     marks += ques.Marks;
                 }
             }
             QuizSolution solution = new QuizSolution();
             solution.StudentId = studentId;
             solution.QuizId    = quizId;
             solution.Correct   = correct;
             solution.Attempted = attempted;
             solution.Marks     = marks;
             data.QuizSolutions.Add(solution);
             data.SaveChanges();
             foreach (var s in solutions)
             {
                 solution.QuestionSolutions.Add(s);
             }
             data.SaveChanges();
         }
     }
 }
Example #17
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();
         }
     }
 }
Example #18
0
 public void SaveStudentData(string Email, Student s)
 {
     using (VCDataModelContainer data = new VCDataModelContainer())
     {
         int count = (from x in data.Students
                      where x.Email.Equals(Email)
                      select x).Count();
         if (count != 0)
         {
             Student s1 = data.Students.First(x => x.Email.Equals(Email));
             s1.EmailConfirmationPIN = "";
             s1.EmailConfirmed       = s.EmailConfirmed;
             s1.FirstName            = s.FirstName;
             s1.Gender   = s.Gender;
             s1.LastName = s.LastName;
             s1.Mobile   = s.Mobile;
             s1.Password = s.Password;
             s1.Username = s.Username;
             s1.Website  = s.Website;
             data.SaveChanges();
         }
     }
 }