Example #1
0
 public GetUserResult GetUser(string username)
 {
     using (var db = new StackOverflowContext()) {
         var result = db.GetUserResult
                      .FromSql("select * from get_user({0})", username).FirstOrDefault();
         return(result);
     }
 }
Example #2
0
 public int GetNoOfMarks(int userId)
 {
     using (var db = new StackOverflowContext()) {
         var result = db.GetMarkedResult.FromSql("SELECT * FROM get_marked({0})", userId)
                      .Count();
         return(result);
     }
 }
Example #3
0
 public GetAuthorResult GetAuthorOfComment(int commentId)
 {
     using (var db = new StackOverflowContext()) {
         var result = db.GetAuthorResult.FromSql("SELECT * FROM get_author_of_comment({0})", commentId)
                      .FirstOrDefault();
         return(result);
     }
 }
Example #4
0
 public GetPostOrCommentResult GetPost(int postId)
 {
     using (var db = new StackOverflowContext()) {
         var result = db.GetPostResults.FromSql("select * from get_post({0})", postId)
                      .FirstOrDefault();
         return(result);
     }
 }
Example #5
0
 public int GetBestSearchedCount(string text)
 {
     using (var db = new StackOverflowContext()) {
         var count = db.SearchResults.FromSql("SELECT * FROM dynamic_search_without_history({0})", text)
                     .Count();
         return(count);
     }
 }
Example #6
0
 public int GetExactSearchedCount(string text)
 {
     using (var db = new StackOverflowContext()) {
         var count = db.SearchResults.FromSql("SELECT * FROM exact_match({0})", text)
                     .Count();
         return(count);
     }
 }
Example #7
0
 public int GetHistoryCount(int userId)
 {
     using (var db = new StackOverflowContext()) {
         var count = db.GetHistoryResult.FromSql("SELECT * FROM get_history({0})", userId)
                     .Count();
         return(count);
     }
 }
Example #8
0
 public GetUserResult GetUserById(int id)
 {
     using (var db = new StackOverflowContext()) {
         var result = db.GetUserResult
                      .FromSql("select * from get_user_by_id({0})", id).FirstOrDefault();
         return(result);
     }
 }
Example #9
0
 public int GetNoOfAnswers(int questionId)
 {
     using (var db = new StackOverflowContext()) {
         var result = db.GetPostResults.FromSql("select * from get_answers({0})", questionId)
                      .Count();
         return(result);
     }
 }
Example #10
0
        public int GetNoOfComments(int postId)
        {
            using (var db = new StackOverflowContext()) {
                var result = db.GetPostResults.FromSql("select * from get_comments({0})", postId)
                             .Count();

                return(result);
            }
        }
Example #11
0
 public bool UpdatePassword(int id, string password, string salt)
 {
     using (var db = new StackOverflowContext()) {
         var updated = db.BooleanResult
                       .FromSql("SELECT * FROM update_password({0},{1},{2}) AS successful", id, password, salt)
                       .First().Successful;
         db.SaveChanges();
         return(updated);
     }
 }
Example #12
0
 public List <GetMarkedResult> GetMarked(int userId, int page = 0, int pageSize = 10)
 {
     using (var db = new StackOverflowContext()) {
         var result = db.GetMarkedResult.FromSql("SELECT * FROM get_marked({0})", userId)
                      .Skip(page * pageSize)
                      .Take(pageSize)
                      .ToList();
         return(result);
     }
 }
Example #13
0
 public bool UpdateLocation(int id, string location)
 {
     using (var db = new StackOverflowContext()) {
         var updated = db.BooleanResult
                       .FromSql("SELECT * FROM update_location({0},{1}) AS successful", id, location)
                       .First().Successful;
         db.SaveChanges();
         return(updated);
     }
 }
Example #14
0
 public bool MakeOrUpdateAnnotation(int userId, int postId, string text)
 {
     using (var db = new StackOverflowContext()) {
         var successful = db.BooleanResult
                          .FromSql("SELECT * FROM make_annotation({0},{1},{2}) AS successful", userId, postId, text)
                          .First().Successful;
         db.SaveChanges();
         return(successful);
     }
 }
Example #15
0
 public bool DeleteAnnotation(int userId, int postId)
 {
     using (var db = new StackOverflowContext()) {
         var deleted = db.BooleanResult
                       .FromSql("SELECT * FROM delete_annotation({0},{1}) AS successful", userId, postId)
                       .First().Successful;
         db.SaveChanges();
         return(deleted);
     }
 }
Example #16
0
 public bool IsMarked(int postId, int userId)
 {
     using (var db = new StackOverflowContext()) {
         var marked = db.BooleanResult
                      .FromSql("SELECT * FROM is_marked({0},{1}) AS successful", postId, userId)
                      .First().Successful;
         db.SaveChanges();
         return(marked);
     }
 }
Example #17
0
 public bool DeleteHistory(int userId)
 {
     using (var db = new StackOverflowContext()) {
         var deleted = db.BooleanResult
                       .FromSql("SELECT * FROM delete_history({0}) AS successful", userId)
                       .First().Successful;
         db.SaveChanges();
         return(deleted);
     }
 }
Example #18
0
 public List <GetPostOrCommentResult> GetComments(int postId, int page = 0, int pageSize = 10)
 {
     using (var db = new StackOverflowContext()) {
         var result = db.GetPostResults.FromSql("select * from get_comments({0})", postId)
                      .Skip(page * pageSize)
                      .Take(pageSize)
                      .ToList();
         return(result);
     }
 }
Example #19
0
 public List <SearchResult> Search(string text, int userId, int page = 0, int pageSize = 10)
 {
     using (var db = new StackOverflowContext()) {
         var result = db.SearchResults.FromSql("SELECT * FROM search_sova({0},{1})", text, userId)
                      .Skip(page * pageSize)
                      .Take(pageSize)
                      .ToList();
         db.SaveChanges();
         return(result);
     }
 }
Example #20
0
 public List <SearchResult> SearchExactMatch(string text, int userId, int page = 0, int pageSize = 10)
 {
     using (var db = new StackOverflowContext()) {
         var result = db.SearchResults.FromSql("SELECT * FROM exact_match({0})", text.Split(' '))
                      .Skip(page * pageSize)
                      .Take(pageSize)
                      .ToList();
         db.SaveChanges();
         return(result);
     }
 }
Example #21
0
        public GetUserResult CreateUser(string email, string username, string password, string location, string salt)
        {
            using (var db = new StackOverflowContext()) {
                var result = db.GetUserResult
                             .FromSql("SELECT * FROM create_user({0},{1},{2},{3},{4})",
                                      email, username, password, location, salt).FirstOrDefault();

                db.SaveChanges();
                return(result);
            }
        }
Example #22
0
 public List <SearchResultWords> SearchRelatedTerm(string text, int userId, bool weighted, int page = 0, int pageSize = 10)
 {
     using (var db = new StackOverflowContext()) {
         var result = db.SearchResultWords
                      .FromSql("SELECT * FROM dynamic_keyword_list" + (weighted ? "_weighted" : "") + "({0}, {1})", text, userId)
                      .Skip(page * pageSize)
                      .Take(pageSize)
                      .ToList();
         db.SaveChanges();
         return(result);
     }
 }
Example #23
0
 public List <SearchResultWords> SearchCoWordQuery(string text, int userId, int page = 0, int pageSize = 10)
 {
     using (var db = new StackOverflowContext()) {
         var result = db.SearchResultWords
                      .FromSql("SELECT * FROM get_co_occurrent_words({0}) order by grade desc", text)
                      .Skip(page * pageSize)
                      .Take(pageSize)
                      .ToList();
         db.SaveChanges();
         return(result);
     }
 }
Example #24
0
 public List <SearchResult> SearchExpandedQuery(string text, int userId, int page = 0, int pageSize = 10)
 {
     text = text.Split(' ').Join("', '");
     using (var db = new StackOverflowContext()) {
         var result = db.SearchResults
                      .FromSql("SELECT * FROM expanded_query_search{0}", text)
                      .Skip(page * pageSize)
                      .Take(pageSize)
                      .ToList();
         db.SaveChanges();
         return(result);
     }
 }