Esempio n. 1
0
 public int GetNumberOfSearches()
 {
     using (var db = new SOVAContext())
     {
         return(db.SearchResults.Count());
     }
 }
Esempio n. 2
0
 public int GetNumberOfMarks()
 {
     using (var db = new SOVAContext())
     {
         return(db.Marked.Count());
     }
 }
Esempio n. 3
0
 public int GetNumberOfAnnotations()
 {
     using (var db = new SOVAContext())
     {
         return(db.Annotations.Count());
     }
 }
Esempio n. 4
0
 public List <WordCloud> GetWordCloud(string word)
 {
     using (var db = new SOVAContext())
     {
         var cloud = db.WordClouds.FromSql("select * from wrdCloud({0})", word);
         return(cloud.ToList());
     }
 }
Esempio n. 5
0
 public Annotations GetAnnotation(int userid, int AnnoId)
 {
     using (var db = new SOVAContext())
     {
         var annotation = db.Annotations
                          .FirstOrDefault(x => x.UserId == userid && x.Id == AnnoId);
         return(annotation);
     }
 }
Esempio n. 6
0
 public Mark GetMark(int userid, int postid)
 {
     using (var db = new SOVAContext())
     {
         var mark = db.Marked
                    .FirstOrDefault(x => x.UserId == userid && x.PostId == postid);
         return(mark);
     }
 }
Esempio n. 7
0
 public Question GetQuestion(int id)
 {
     using (var db = new SOVAContext())
     {
         var question = db.Questions
                        .FirstOrDefault(x => x.Id == id);
         return(question);
     }
 }
Esempio n. 8
0
 //----------------users----------------
 public List <User> GetUsers()
 {
     using (var db = new SOVAContext())
     {
         var userss = db.Users
                      .ToList();
         return(userss);
     }
 }
Esempio n. 9
0
 //-----------------PostLinks--------------------------
 public List <PostLink> GetPostLinksByQuestion(int id)
 {
     using (var db = new SOVAContext())
     {
         var qpostlinks = db.PostLinks
                          .Where(x => x.Id == id);
         return(qpostlinks.ToList());
     }
 }
Esempio n. 10
0
 public List <Answer> GetAnswersByParent(int id)
 {
     using (var db = new SOVAContext())
     {
         var answerbyparent = db.Answers
                              .Where(x => x.ParentId == id);
         return(answerbyparent.ToList());
     }
 }
Esempio n. 11
0
        //Answers

        public List <Answer> GetAnswers()
        {
            using (var db = new SOVAContext())
            {
                var answers = db.Answers.ToList();

                return(answers);
            }
        }
Esempio n. 12
0
 public User GetUser(int id)
 {
     using (var db = new SOVAContext())
     {
         var user = db.Users
                    .Where(x => x.Id == id)
                    .FirstOrDefault();
         return(user);
     }
 }
Esempio n. 13
0
 public Answer GetAnswer(int id)
 {
     using (var db = new SOVAContext())
     {
         var answer = db.Answers
                      .Where(x => x.Id == id)
                      .FirstOrDefault();
         return(answer);
     }
 }
Esempio n. 14
0
 public List <Comment> GetCommentsByAnswer(int id)
 {
     using (var db = new SOVAContext())
     {
         var answercomment = db.Comments
                             .Where(x => x.PostId == id)
                             .ToList();
         return(answercomment);
     }
 }
Esempio n. 15
0
 public List <SearchResult> GetQuestionsByString(string title, int page, int pageSize)
 {
     using (var db = new SOVAContext())
     {
         var question = db.SearchResults.FromSql("select * from TFIDF_MATCH({0})", title);
         return(question
                .Skip(page * pageSize)
                .Take(pageSize)
                .ToList());
     }
 }
Esempio n. 16
0
        //Comments
        public List <Comment> GetQuestionComments(int id)
        {
            using (var db = new SOVAContext())
            {
                var commentsToQuestion = db.Comments

                                         .Where(x => x.PostId == id)
                                         .ToList();
                return(commentsToQuestion);
            }
        }
Esempio n. 17
0
 public List <SearchHistories> SearchHistories(int id)
 {
     using (var db = new SOVAContext())
     {
         var question = db.SearchHistory
                        .Where(x => x.UserId == id)
                        .OrderByDescending(x => x.Date)
                        .ToList();
         //.FirstOrDefault();
         return(question);
     }
 }
Esempio n. 18
0
        //Questions

        public List <Question> GetQuestions(int page, int pageSize)
        {
            using (var db = new SOVAContext())
            {
                var questions = db.Questions
                                .Skip(page * pageSize)
                                .Take(pageSize)
                                .ToList();

                return(questions);
            }
        }
Esempio n. 19
0
        public List <Annotations> GetAnnotations(int userid, int page, int pageSize)
        {
            using (var db = new SOVAContext())
            {
                var annotations = db.Annotations
                                  .Where(x => x.UserId == userid)
                                  .Skip(page * pageSize)
                                  .Take(pageSize)
                                  .ToList();

                return(annotations);
            }
        }
Esempio n. 20
0
 public List <Mark> GetMarks(int userid, int page, int pageSize)
 {
     using (var db = new SOVAContext())
     {
         var marks = db.Marked
                     .Where(x => x.UserId == userid)
                     .Skip(page * pageSize)
                     .Take(pageSize)
                     .ToList();
         //.Where(x => x.UserId == id)
         //.ToList();
         return(marks);
     }
 }
Esempio n. 21
0
 public bool UpdateAnnotation(string body, int id)
 {
     using (var db = new SOVAContext())
     {
         var anno = db.Annotations.FirstOrDefault(x => x.Id == id);
         if (anno != null)
         {
             anno.Body = body;
             db.SaveChanges();
             return(true);
         }
         return(false);
     }
 }
Esempio n. 22
0
 // when update is run the createtionDate is updated to. Need to be fixed.
 public bool UpdateUser(int userId, string newName, string newPassword)
 {
     using (var db = new SOVAContext())
     {
         var user = db.Users.FirstOrDefault(x => x.Id == userId);
         if (user != null)
         {
             user.UserName = newName;
             user.Password = newPassword;
             db.SaveChanges();
             return(true);
         }
         return(false);
     }
 }
Esempio n. 23
0
 public User CreateUser(string name, string password)
 {
     using (var db = new SOVAContext())
     {
         var creationdate = DateTime.Now;
         var newUser      = new User()
         {
             UserName     = name,
             Password     = password,
             CreationDate = creationdate
         };
         db.Users.Add(newUser);
         db.SaveChanges();
         return(newUser);
     }
 }
Esempio n. 24
0
 public Mark CreateMarking(int postid, int userid)
 {
     using (var db = new SOVAContext())
     {
         var creationdate = DateTime.Now;
         var newmark      = new Mark()
         {
             CreationDate = creationdate,
             PostId       = postid,
             UserId       = userid
         };
         db.Marked.Add(newmark);
         db.SaveChanges();
         return(newmark);
     }
 }
Esempio n. 25
0
 //--------------------- Searchs ----------------
 public SearchHistories SaveSearch(string newSearch, int newUserId)
 {
     using (var db = new SOVAContext())
     {
         var currentDate      = DateTime.Now;
         var newSearchHistory = new SearchHistories()
         {
             Search = newSearch,
             UserId = newUserId,
             Date   = currentDate
         };
         db.SearchHistory.Add(newSearchHistory);
         db.SaveChanges();
         return(newSearchHistory);
     }
 }
Esempio n. 26
0
        //---------------- ANNOTATIONS ------------------



        public Annotations CreateAnnotation(string body, int userid, int postid)
        {
            using (var db = new SOVAContext())
            {
                var creationdate  = DateTime.Now;
                var newannotation = new Annotations()
                {
                    CreationDate = creationdate,
                    Body         = body,
                    UserId       = userid,
                    PostId       = postid
                };
                db.Annotations.Add(newannotation);
                db.SaveChanges();
                return(newannotation);
            }
        }
Esempio n. 27
0
 public bool DeleteUser(int id)
 {
     try
     {
         using (var db = new SOVAContext())
         {
             var deluser = db.Users.Find(id);
             db.Users.Remove(deluser);
             db.SaveChanges();
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Esempio n. 28
0
 public bool DeleteAnnotation(int id)
 {
     try
     {
         using (var db = new SOVAContext())
         {
             var delannotation = new Annotations()
             {
                 Id = id
             };
             db.Annotations.Remove(delannotation);
             db.SaveChanges();
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Esempio n. 29
0
 public bool DeleteMarking(int userid, int postid)
 {
     try
     {
         using (var db = new SOVAContext())
         {
             var delmarking = new Mark()
             {
                 UserId = userid,
                 PostId = postid
             };
             db.Marked.Remove(delmarking);
             db.SaveChanges();
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }