public void RemoveComment(long commentId) { using (var entities = new SocialFeedEntities()) { var comment = entities.UserComment.FirstOrDefault(p => p.Id == commentId); comment.IsDeleted = true; entities.SaveChanges(); } }
public void UnfollowUser(string userId, string followerId) { using (var entities = new SocialFeedEntities()) { var record = entities.UserFollower.FirstOrDefault(p => p.FollowerId == followerId && p.UserId == userId); if (record != null) { entities.UserFollower.Remove(record); entities.SaveChanges(); } } }
public void FollowUser(string userId, string followerId) { using (var entities = new SocialFeedEntities()) { if (!entities.UserFollower.Any(t => t.UserId == userId && t.FollowerId == followerId)) { entities.UserFollower.Add(new UserFollower { UserId = userId, FollowerId = followerId }); entities.SaveChanges(); } } }
public void FollowGroup(string groupId, string followerId) { using (var entities = new SocialFeedEntities()) { if (!entities.GroupFollower.Any(t => t.GroupId == groupId && t.FollowerId == followerId)) { entities.GroupFollower.Add(new GroupFollower { GroupId = groupId, FollowerId = followerId }); entities.SaveChanges(); } } }
public bool RemovePost(string postId) { using (var entities = new SocialFeedEntities()) { var post = entities.WallPost.FirstOrDefault(p => p.Id == postId); if (post != null) { post.IsDeleted = true; entities.SaveChanges(); return(true); } return(false); } }
public bool UnlikePost(string postId, string userId) { using (var entities = new SocialFeedEntities()) { var likeEntry = entities.WallPostLike.FirstOrDefault(t => t.CreatedBy == userId && t.WallPostId == postId); if (likeEntry != null) { entities.WallPostLike.Remove(likeEntry); entities.SaveChanges(); return(true); } return(false); } }
public bool LikePost(string postId, string userId) { using (var entities = new SocialFeedEntities()) { if (!entities.WallPostLike.Any(t => t.CreatedBy == userId && t.WallPostId == postId)) { entities.WallPostLike.Add(new WallPostLike { CreatedDate = DateTime.Now, WallPostId = postId, CreatedBy = userId }); entities.SaveChanges(); return(true); } return(false); } }
public bool LikeComment(long commentId, string userId) { using (var entities = new SocialFeedEntities()) { if (!entities.UserCommentLike.Any(t => t.CreatedBy == userId && t.CommentId == commentId)) { entities.UserCommentLike.Add(new UserCommentLike { CreatedDate = DateTime.Now, CommentId = commentId, CreatedBy = userId }); entities.SaveChanges(); return(true); } } return(false); }
public DateTime?UpdateComment(CommentUpdateRequest model) { using (var entities = new SocialFeedEntities()) { var comment = entities.UserComment.FirstOrDefault(p => p.Id == model.CommentId && p.IsDeleted == false); if (comment != null) { comment.ModifiedDate = DateTime.Now; comment.Body = model.Body; entities.SaveChanges(); return(comment.ModifiedDate.Value); } } return(null); }
public DateTime?UpdatePost(WallPostUpdateRequest model) { using (var entities = new SocialFeedEntities()) { var post = entities.WallPost.FirstOrDefault(p => p.Id == model.PostId && p.IsDeleted == false); if (post != null) { post.Body = model.Body; post.ModifiedDate = DateTime.Now; post.PostType = (byte)model.PostType; entities.SaveChanges(); return(post.ModifiedDate.Value); } } return(null); }
public CommentCreateResponse SaveComment(CommentCreateRequest model) { var entry = new UserComment { WallPostId = model.WallPostId, Body = model.Body, CreatedBy = model.CreatedBy, CreatedDate = DateTime.Now, IsDeleted = false }; using (var entities = new SocialFeedEntities()) { entities.UserComment.Add(entry); entities.SaveChanges(); } return(new CommentCreateResponse { Id = entry.Id, CreatedDate = entry.CreatedDate }); }
public WallPostCreateResponse SavePost(WallPostCreateRequest model) { var newEntryId = Guid.NewGuid().ToString(); var entry = new WallPost { Body = model.Body, CreatedBy = model.PostedBy, Id = newEntryId, CreatedDate = DateTime.Now, PostType = (byte)model.PostType, IsDeleted = false }; if (model.TargetWall.WallOwnerType == WallType.user) { entry.UserWall = new UserWall { UserId = model.TargetWall.OwnerId, WallPostId = newEntryId }; } else { entry.GroupWall = new GroupWall { GroupId = model.TargetWall.OwnerId, WallPostId = newEntryId }; } using (var entities = new SocialFeedEntities()) { entities.WallPost.Add(entry); entities.SaveChanges(); } return(new WallPostCreateResponse { PostId = newEntryId, CreatedDate = entry.CreatedDate }); }