Пример #1
0
 public static bool AddPost(Post newPost)
 {
     using (var db = new TwitterOnVaadinEntities())
     {
         newPost.id = 1;
         db.Posts.AddObject(newPost);
         db.SaveChanges();
     }
     return true;
 }
Пример #2
0
 public static bool DeleteBlockedUser(int userId, int blockedId)
 {
     using (var db = new TwitterOnVaadinEntities())
     {
         var blockedUsers = db.BlockedLists.FirstOrDefault(e => e.User == userId && e.BlockedUser == blockedId);
         db.BlockedLists.DeleteObject(blockedUsers);
         db.SaveChanges();
     }
     return true;
 }
Пример #3
0
 public static bool AddUser(User newUser)
 {
     using (var db = new TwitterOnVaadinEntities())
     {
         if (db.Users.FirstOrDefault(e => e.Username == newUser.Username) != null)
         {
             db.Users.AddObject(newUser);
             db.SaveChanges();
             return true;
         }
         return false;
     }
 }
Пример #4
0
        public static bool AddFriendUser(int userId, int friendId)
        {
            using (var db = new TwitterOnVaadinEntities())
            {
                var friendUser = new FriendList
                {
                    Friend = friendId,
                    User = userId,
                };

                db.FriendLists.AddObject(friendUser);
                db.SaveChanges();
            }
            return true;
        }
Пример #5
0
        public static bool AddBlockedUser(int userId, int blockedId)
        {
            using (var db = new TwitterOnVaadinEntities())
            {
                var blockedUsers = new BlockedList
                {
                    BlockedUser = blockedId,
                    User = userId,
                };

                db.BlockedLists.AddObject(blockedUsers);
                db.SaveChanges();
            }
            return true;
        }
Пример #6
0
 public static bool DeletePost(int postId)
 {
     using (var db = new TwitterOnVaadinEntities())
     {
         var post = db.Posts.FirstOrDefault(e => e.id == postId);
         db.Posts.DeleteObject(post);
         db.SaveChanges();
     }
     return true;
 }
Пример #7
0
 public static bool DeleteFriendUser(int userId, int friendId)
 {
     using (var db = new TwitterOnVaadinEntities())
     {
         var friendUser = db.FriendLists.FirstOrDefault(e => e.User == userId && e.Friend == friendId);
         db.FriendLists.DeleteObject(friendUser);
         db.SaveChanges();
     }
     return true;
 }
Пример #8
0
 public static bool UpdateUser(User newUser)
 {
     using (var db = new TwitterOnVaadinEntities())
     {
         var user = db.Users.FirstOrDefault(e => e.id == newUser.id);
         if (user != null)
         {
             user = newUser;
         }
         db.SaveChanges();
     }
     return true;
 }
Пример #9
0
 public static bool UpdatePost(Post newPost)
 {
     using (var db = new TwitterOnVaadinEntities())
     {
         var post = db.Posts.FirstOrDefault(e => e.id == newPost.id);
         if (post != null)
         {
             post = newPost;
         }
         db.SaveChanges();
     }
     return true;
 }