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

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

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