Beispiel #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);
     }
 }
Beispiel #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);
     }
 }
Beispiel #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);
     }
 }
Beispiel #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);
     }
 }
Beispiel #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);
     }
 }
Beispiel #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);
     }
 }
Beispiel #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);
     }
 }
Beispiel #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);
     }
 }
Beispiel #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);
     }
 }
Beispiel #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);
            }
        }
Beispiel #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);
     }
 }
Beispiel #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);
     }
 }
Beispiel #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);
     }
 }
Beispiel #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);
     }
 }
Beispiel #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);
     }
 }
Beispiel #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);
     }
 }
Beispiel #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);
     }
 }
Beispiel #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);
     }
 }
Beispiel #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);
     }
 }
Beispiel #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);
     }
 }
Beispiel #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);
            }
        }
Beispiel #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);
     }
 }
Beispiel #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);
     }
 }
Beispiel #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);
     }
 }