Пример #1
0
        public void UpdateUser(FrameworkTables.User user)
        {
            SovaContext db = new SovaContext();

            db.Update(user);
            db.SaveChanges();
        }
Пример #2
0
        //update comment
        public void UpdateComment(Comment comment)
        {
            SovaContext db = new SovaContext();

            db.Comments.Update(comment);
            db.SaveChanges();
        }
Пример #3
0
        //update post
        public void UpdatePost(Post post)
        {
            SovaContext db = new SovaContext();

            db.Posts.Update(post);
            db.SaveChanges();
        }
Пример #4
0
        public List <FrameworkTables.User> GetUsers(PagingAttributes pagingAttributes)
        {
            SovaContext db = new SovaContext();

            return(db.FrameworkUsers
                   .Skip(pagingAttributes.Page * pagingAttributes.PageSize)
                   .Take(pagingAttributes.PageSize).ToList());
        }
Пример #5
0
        ///////////////////////
        //
        // Posts
        //
        ///////////////////////

        // Gets All Posts
        public IList <Post> GetPosts(PagingAttributes pagingAttributes)
        {
            SovaContext db = new SovaContext();

            return(db.Posts.Skip(pagingAttributes.Page * pagingAttributes.PageSize)
                   .Take(pagingAttributes.PageSize)
                   .ToList());
        }
Пример #6
0
        ///////////////////////
        //
        // Users
        //
        ///////////////////////

        // Gets All GetUsers
        public IList <User> QAGetUsers(PagingAttributes pagingAttributes)
        {
            SovaContext db = new SovaContext();

            return(db.Users.Skip(pagingAttributes.Page * pagingAttributes.PageSize)
                   .Take(pagingAttributes.PageSize)
                   .ToList());
        }
Пример #7
0
        //create new post
        public void CreatePost(Post post)
        {
            SovaContext db = new SovaContext();

            post.Id           = db.Posts.Max(x => x.Id) + 1;
            post.CreationDate = DateTime.Now;
            db.Add(post);
            db.SaveChanges();
        }
Пример #8
0
        //create new comment
        public void CreateComment(Comment comment)
        {
            SovaContext db = new SovaContext();

            comment.Id         = db.Comments.Max(x => x.Id) + 1;
            comment.CreateDate = DateTime.Now;
            db.Add(comment);
            db.SaveChanges();
        }
Пример #9
0
        //delete comment
        public bool DeleteComment(int commentId)
        {
            SovaContext db      = new SovaContext();
            var         comment = db.Comments.Find(commentId);

            if (comment == null)
            {
                return(false);
            }
            db.Remove(comment);
            db.SaveChanges();
            return(true);
        }
Пример #10
0
        public bool DeleteUser(int userId)
        {
            SovaContext db   = new SovaContext();
            var         user = db.FrameworkUsers.Find(userId);

            if (user == null)
            {
                return(false);
            }
            db.Remove(user);
            db.SaveChanges();
            return(true);
        }
Пример #11
0
        //delete post
        public bool DeletePost(int postId)
        {
            SovaContext db   = new SovaContext();
            var         post = db.Posts.Find(postId);

            if (post == null)
            {
                return(false);
            }
            db.Remove(post);
            db.SaveChanges();
            return(true);
        }
Пример #12
0
        public void CreateUser(FrameworkTables.User user)
        {
            SovaContext db      = new SovaContext();
            var         tmpList = db.Users.ToList();

            if (tmpList.Count() == 0)
            {
                user.Id = 1;
            }
            else
            {
                user.Id = db.FrameworkUsers.Max(x => x.Id) + 1;
            }
            db.Add(user);
            db.SaveChanges();
        }
Пример #13
0
        // get comment by id
        public Comment GetComment(int commentId)
        {
            SovaContext db = new SovaContext();

            return(db.Comments.Find(commentId));
        }
Пример #14
0
        public LinkPost GetLinkPostId(int linkId)
        {
            SovaContext db = new SovaContext();

            return(db.LinkPosts.Find(linkId));
        }
Пример #15
0
        public int NumberGetLinkPost()
        {
            var db = new SovaContext();

            return(db.LinkPosts.Count());
        }
Пример #16
0
        public int NumberOfUsers()
        {
            var db = new SovaContext();

            return(db.Users.Count());
        }
Пример #17
0
        // Gets Number Of Posts
        public int NumberOfPosts()
        {
            var db = new SovaContext();

            return(db.Posts.Count());
        }
Пример #18
0
        public FrameworkTables.User GetUser(int userId)
        {
            SovaContext db = new SovaContext();

            return(db.FrameworkUsers.Find(userId));
        }
Пример #19
0
        //Get a post by Id
        public User QAGetUser(int userId)
        {
            SovaContext db = new SovaContext();

            return(db.Users.Find(userId));
        }
Пример #20
0
        ///////////////////////
        //
        // Linkpost
        //
        ///////////////////////

        // Gets All LinkPosts

        // Gets Number Of Comments
        public int NumberOfComments()
        {
            var db = new SovaContext();

            return(db.Comments.Count());
        }
Пример #21
0
        //Get a post by Id
        public Post GetPost(int postId)
        {
            SovaContext db = new SovaContext();

            return(db.Posts.Find(postId));
        }
Пример #22
0
        public int numOfPages()
        {
            SovaContext db = new SovaContext();

            return(db.FrameworkUsers.Count());
        }