public Topic getTopic(string subject, string topic) { using (var db = new MedTrainDBContext()) { return(db.Topics.Find(topic, subject)); } }
public List <Subject> getSubjects() { using (var db = new MedTrainDBContext()) { return(db.Subjects.ToList()); } }
public Answer getAnswer(int answerId) { using (var db = new MedTrainDBContext()) { return(db.Answers.Find(answerId)); } }
public Admin getAdmin(string UserId) { using (var db = new MedTrainDBContext()) { return(db.Admins.Find(UserId)); } }
public Subject getSubject(string subject) { using (var db = new MedTrainDBContext()) { return(db.Subjects.Find(subject)); } }
public void removeGroupMember(GroupMember gm) { using (var db = new MedTrainDBContext()) { db.GroupsMembers.Remove(gm); } }
public Test getTest(int TestId) { using (var db = new MedTrainDBContext()) { return(db.Tests.Find(TestId)); } }
public Group getGroup(string adminId, string groupName) { using (var db = new MedTrainDBContext()) { return(db.Groups.Find(adminId, groupName)); } }
public UserLevel getUserLevel(string eMail, string subject, string topic) { using (var db = new MedTrainDBContext()) { return(db.UsersLevels.Find(eMail, topic, subject)); } }
public List <Question> getQuestions(string subject, string topic) { using (var db = new MedTrainDBContext()) { if (getTopic(subject, topic) == null) { return(new List <Question>()); } var query = from q in db.Questions where q.SubjectId.Equals(subject) && !q.isDeleted select q; List <Question> ans = new List <Question>(); foreach (Question q in query) { var diagnoses = from d in db.Diagnoses where d.QuestionId == q.QuestionId select d; foreach (Diagnosis d in diagnoses) { if (d.TopicId.Equals(topic)) { ans.Add(q); break; } } } return(ans); } }
public Question getQuestion(int id) { using (var db = new MedTrainDBContext()) { return(db.Questions.Find(id)); } }
public void updateGroupMember(GroupMember gm) { using (var db = new MedTrainDBContext()) { db.Entry(gm).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } }
public void updateUserLevel(UserLevel ul) { using (var db = new MedTrainDBContext()) { db.Entry(ul).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } }
public void updateQuestion(Question q) { using (var db = new MedTrainDBContext()) { db.Entry(q).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } }
public void removeGroup(Group g) { using (var db = new MedTrainDBContext()) { Group group = db.Groups.Find(g.AdminId, g.name); db.Groups.Remove(group); db.SaveChanges(); } }
public List <GroupMember> getUserInvitations(string userId) { using (var db = new MedTrainDBContext()) { var query = from gm in db.GroupsMembers where gm.UserId.Equals(userId) && !gm.invitationAccepted select gm; return(query.ToList()); } }
public List <GroupMember> getGroupMembers(string groupName, string adminId) { using (var db = new MedTrainDBContext()) { var query = from gm in db.GroupsMembers where gm.GroupName.Equals(groupName) && gm.AdminId.Equals(adminId) && gm.invitationAccepted select gm; return(query.ToList()); } }
public List <Diagnosis> getQuestionDiagnoses(int qId) { using (var db = new MedTrainDBContext()) { var query = from d in db.Diagnoses where d.QuestionId == qId select d; return(query.ToList()); } }
public List <QuestionImage> getQuestionImages(int qId) { using (var db = new MedTrainDBContext()) { var query = from i in db.Images where i.QuestionId == qId select i; return(query.ToList()); } }
public List <Topic> getTopics(string subject) { using (var db = new MedTrainDBContext()) { var query = from t in db.Topics where t.SubjectId.Equals(subject) select t; return(query.ToList()); } }
public User getUser(string UserId) { using (var db = new MedTrainDBContext()) { var query = from u in db.Users where u.UserId.Equals(UserId) select u; return(query.Count() == 1 ? query.ToList()[0] : null); } }
public List <TestQuestion> getTestQuestions(int TestId) { using (var db = new MedTrainDBContext()) { var query = from tq in db.TestsQuestions where tq.TestId == TestId select tq; return(query.ToList()); } }
public List <Group> getAdminsGroups(string adminId) { using (var db = new MedTrainDBContext()) { var query = from g in db.Groups where g.AdminId.Equals(adminId) select g; return(query.ToList()); } }
public List <GroupTest> getGroupTests(string groupName, string adminId) { using (var db = new MedTrainDBContext()) { var query = from gt in db.GroupsTests where gt.GroupName.Equals(groupName) && gt.AdminId.Equals(adminId) select gt; return(query.ToList()); } }
public List <Test> getAllTests(string subject) { using (var db = new MedTrainDBContext()) { var query = from t in db.Tests where t.subject.Equals(subject) select t; return(query.ToList()); } }
public List <GroupTestAnswer> getGroupTestAnswers(string groupName, string adminId, int TestId) { using (var db = new MedTrainDBContext()) { var query = from gta in db.GroupsTestsAnswers where gta.GroupName.Equals(groupName) && gta.AdminId.Equals(adminId) && gta.TestId == TestId select gta; return(query.ToList()); } }
public bool hasInvitation(string userId, string groupName, string adminId) { using (var db = new MedTrainDBContext()) { var query = from gm in db.GroupsMembers where gm.UserId.Equals(userId) && gm.GroupName.Equals(groupName) && gm.AdminId.Equals(adminId) && !gm.invitationAccepted select gm; return(query.Count() == 1); } }
public void addUser(User u) { using (var db = new MedTrainDBContext()) { if (db.Users.Find(u.UserId) != null) { return; } db.Users.Add(u); db.SaveChanges(); } }
public void addGroupMember(GroupMember gm) { using (var db = new MedTrainDBContext()) { if (db.Groups.Find(gm.AdminId, gm.GroupName) == null || db.GroupsMembers.Find(gm.GroupName, gm.AdminId, gm.UserId) != null) { return; } db.GroupsMembers.Add(gm); db.SaveChanges(); } }
public void addTest(Test t) { using (var db = new MedTrainDBContext()) { if (db.Admins.Find(t.AdminId) == null || db.Subjects.Find(t.subject) == null || db.Tests.Find(t.TestId) != null) { return; } db.Tests.Add(t); db.SaveChanges(); } }