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(); } } } }
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(); } } }
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); } } } }
public Announcement GetAnnouncement(int id) { VCDataModelContainer data = new VCDataModelContainer(); Announcement a = data.Announcements.Find(id); return(a); }
public Assignment GetAssignment(int id) { VCDataModelContainer data = new VCDataModelContainer(); Assignment a = data.Assignments.Find(id); return(a); }
public Quiz GetQuiz(int id) { VCDataModelContainer data = new VCDataModelContainer(); Quiz q = data.Quizs.Find(id); return(q); }
public void AddTeacher(Teacher teacher) { using (VCDataModelContainer data = new VCDataModelContainer()) { data.Teachers.Add(teacher); data.SaveChanges(); } }
public void ChangePassword(int sId, string Password) { using (VCDataModelContainer data = new VCDataModelContainer()) { Student s = data.Students.Find(sId); s.Password = Password; data.SaveChanges(); } }
public void SaveDiscussion(int cid, Discussion discussion) { using (VCDataModelContainer data = new VCDataModelContainer()) { Course c = data.Courses.Find(cid); c.Discussions.Add(discussion); data.SaveChanges(); } }
public void AddComment(int did, DiscussionComment comment) { using (VCDataModelContainer data = new VCDataModelContainer()) { Discussion d = data.Discussions.Find(did); d.Comments.Add(comment); data.SaveChanges(); } }
public void MakeAnnouncement(int cid, Announcement announcement) { using (VCDataModelContainer data = new VCDataModelContainer()) { Course c = data.Courses.Find(cid); c.Announcements.Add(announcement); data.SaveChanges(); } }
public void ChangePassword(int tId, string Password) { using (VCDataModelContainer data = new VCDataModelContainer()) { Teacher t = data.Teachers.Find(tId); t.Password = Password; data.SaveChanges(); } }
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); } }
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); } }
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); } }
public void AddStudentByEmail(string Email) { using (VCDataModelContainer data = new VCDataModelContainer()) { Student s = new Student { Email = Email, EmailConfirmed = false }; data.Students.Add(s); data.SaveChanges(); } }
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(); } }
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(); } } }
public Teacher GetInstructor(int cid) { using (VCDataModelContainer data = new VCDataModelContainer()) { Course c = data.Courses.Find(cid); if (c == null) { return(null); } return(c.Teacher); } }
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); } }
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(); } }
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(); } }
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); } }
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(); } } }
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); } } } }
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(); } } }
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); } }
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); }
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); } }
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); } }