Example #1
0
 public Topic getTopic(string subject, string topic)
 {
     using (var db = new MedTrainDBContext())
     {
         return(db.Topics.Find(topic, subject));
     }
 }
Example #2
0
 public List <Subject> getSubjects()
 {
     using (var db = new MedTrainDBContext())
     {
         return(db.Subjects.ToList());
     }
 }
Example #3
0
 public Answer getAnswer(int answerId)
 {
     using (var db = new MedTrainDBContext())
     {
         return(db.Answers.Find(answerId));
     }
 }
Example #4
0
 public Admin getAdmin(string UserId)
 {
     using (var db = new MedTrainDBContext())
     {
         return(db.Admins.Find(UserId));
     }
 }
Example #5
0
 public Subject getSubject(string subject)
 {
     using (var db = new MedTrainDBContext())
     {
         return(db.Subjects.Find(subject));
     }
 }
Example #6
0
 public void removeGroupMember(GroupMember gm)
 {
     using (var db = new MedTrainDBContext())
     {
         db.GroupsMembers.Remove(gm);
     }
 }
Example #7
0
 public Test getTest(int TestId)
 {
     using (var db = new MedTrainDBContext())
     {
         return(db.Tests.Find(TestId));
     }
 }
Example #8
0
 public Group getGroup(string adminId, string groupName)
 {
     using (var db = new MedTrainDBContext())
     {
         return(db.Groups.Find(adminId, groupName));
     }
 }
Example #9
0
 public UserLevel getUserLevel(string eMail, string subject, string topic)
 {
     using (var db = new MedTrainDBContext())
     {
         return(db.UsersLevels.Find(eMail, topic, subject));
     }
 }
Example #10
0
 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);
     }
 }
Example #11
0
 public Question getQuestion(int id)
 {
     using (var db = new MedTrainDBContext())
     {
         return(db.Questions.Find(id));
     }
 }
Example #12
0
 public void updateGroupMember(GroupMember gm)
 {
     using (var db = new MedTrainDBContext())
     {
         db.Entry(gm).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
Example #13
0
 public void updateUserLevel(UserLevel ul)
 {
     using (var db = new MedTrainDBContext())
     {
         db.Entry(ul).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
Example #14
0
 public void updateQuestion(Question q)
 {
     using (var db = new MedTrainDBContext())
     {
         db.Entry(q).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
Example #15
0
 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();
     }
 }
Example #16
0
 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());
     }
 }
Example #17
0
 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());
     }
 }
Example #18
0
 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());
     }
 }
Example #19
0
 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());
     }
 }
Example #20
0
 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());
     }
 }
Example #21
0
 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);
     }
 }
Example #22
0
 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());
     }
 }
Example #23
0
 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());
     }
 }
Example #24
0
 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());
     }
 }
Example #25
0
 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());
     }
 }
Example #26
0
 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());
     }
 }
Example #27
0
 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);
     }
 }
Example #28
0
 public void addUser(User u)
 {
     using (var db = new MedTrainDBContext())
     {
         if (db.Users.Find(u.UserId) != null)
         {
             return;
         }
         db.Users.Add(u);
         db.SaveChanges();
     }
 }
Example #29
0
 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();
     }
 }
Example #30
0
 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();
     }
 }