예제 #1
0
 public int GetNumberOfSearches()
 {
     using (var db = new SOVAContext())
     {
         return(db.SearchResults.Count());
     }
 }
예제 #2
0
 public int GetNumberOfMarks()
 {
     using (var db = new SOVAContext())
     {
         return(db.Marked.Count());
     }
 }
예제 #3
0
 public int GetNumberOfAnnotations()
 {
     using (var db = new SOVAContext())
     {
         return(db.Annotations.Count());
     }
 }
예제 #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());
     }
 }
예제 #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);
     }
 }
예제 #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);
     }
 }
예제 #7
0
 public Question GetQuestion(int id)
 {
     using (var db = new SOVAContext())
     {
         var question = db.Questions
                        .FirstOrDefault(x => x.Id == id);
         return(question);
     }
 }
예제 #8
0
 //----------------users----------------
 public List <User> GetUsers()
 {
     using (var db = new SOVAContext())
     {
         var userss = db.Users
                      .ToList();
         return(userss);
     }
 }
예제 #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());
     }
 }
예제 #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());
     }
 }
예제 #11
0
        //Answers

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

                return(answers);
            }
        }
예제 #12
0
 public User GetUser(int id)
 {
     using (var db = new SOVAContext())
     {
         var user = db.Users
                    .Where(x => x.Id == id)
                    .FirstOrDefault();
         return(user);
     }
 }
예제 #13
0
 public Answer GetAnswer(int id)
 {
     using (var db = new SOVAContext())
     {
         var answer = db.Answers
                      .Where(x => x.Id == id)
                      .FirstOrDefault();
         return(answer);
     }
 }
예제 #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);
     }
 }
예제 #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());
     }
 }
예제 #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);
            }
        }
예제 #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);
     }
 }
예제 #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);
            }
        }
예제 #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);
            }
        }
예제 #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);
     }
 }
예제 #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);
     }
 }
예제 #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);
     }
 }
예제 #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);
     }
 }
예제 #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);
     }
 }
예제 #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);
     }
 }
예제 #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);
            }
        }
예제 #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);
     }
 }
예제 #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);
     }
 }
예제 #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);
     }
 }