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

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

                return(answers);
            }
        }
Exemplo 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);
     }
 }
Exemplo 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);
     }
 }
Exemplo 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);
     }
 }
Exemplo 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());
     }
 }
Exemplo 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);
            }
        }
Exemplo 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);
     }
 }
Exemplo 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);
            }
        }
Exemplo 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);
            }
        }
Exemplo 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);
     }
 }
Exemplo 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);
     }
 }
Exemplo 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);
     }
 }
Exemplo 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);
     }
 }
Exemplo 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);
     }
 }
Exemplo 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);
     }
 }
Exemplo 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);
            }
        }
Exemplo 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);
     }
 }
Exemplo 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);
     }
 }
Exemplo 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);
     }
 }