Пример #1
0
        public string AddPost(WallPostCreateRequest request)
        {
            var result = wallPostRepo.SavePost(request);

            if (result != null && !string.IsNullOrWhiteSpace(result.PostId))
            {
                try
                {
                    var cacheEntry = MapRequestToCacheModel(request, result);
                    wallPostCacheRepo.SavePost(cacheEntry);
                    if (request.TargetWall.WallOwnerType == WallType.group)
                    {
                        var postIds = wallPostRepo.GetGroupWallIds(request.TargetWall.OwnerId, 40);
                        groupWallCacheRepo.RefreshGroupWall(request.TargetWall.OwnerId, postIds);
                    }
                }
                catch (Exception ex)
                {
                    logger.Error(string.Format(
                                     "[AddPost] Error updating wallPost cache for postId : {0}", result), ex);
                }
                return(result.PostId);
            }
            return(null);
        }
Пример #2
0
        public ActionResult CreateEntry(WallPostCreateRequest request)
        {
            var activeUserId = ActiveUser.Username;

            request.PostedBy = new Actor {
                Id = activeUserId, ActorTypeId = (short)ActorType.user
            };
            //If target user is not specified, user is posting his/her own wall}
            request.WallOwner = request.WallOwner != null   ? request.WallOwner : request.PostedBy;
            var entryId = wallEntryService.CreatePost(request);

            return(Json(entryId));
        }
Пример #3
0
 private WallPostCacheModel MapRequestToCacheModel(WallPostCreateRequest request, WallPostCreateResponse response)
 {
     return(new WallPostCacheModel
     {
         Id = response.PostId,
         Body = request.Body,
         PostedBy = request.PostedBy,
         PostType = (short)request.PostType,
         TargetWall = new WallCacheModel {
             Id = request.TargetWall.OwnerId, WallOwnerTypeId = (short)request.TargetWall.WallOwnerType
         },
         CreatedDate = response.CreatedDate
     });
 }
Пример #4
0
        private void ShareMultipleButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(ShareTextBox.Text))
            {
                MessageBox.Show("İçerik girmediniz!");
                return;
            }

            var request = new WallPostCreateRequest();

            request.Body     = ShareTextBox.Text;
            request.PostedBy = FormHelper.Username;
            request.PostType = WallPostType.text;
            if (ShareToOwnWallCheckbox.Checked)
            {
                request.TargetWall = new WallModel {
                    OwnerId = FormHelper.Username, WallOwnerType = WallType.user
                };
            }
            else
            {
                var ownerType = WallSelectionComboBox.Text == "Grup" ? WallType.group : WallType.user;
                request.TargetWall = new WallModel {
                    OwnerId = WallOwnerTextBox.Text, WallOwnerType = ownerType
                };
            }

            var provider = new WallPostProvider();

            for (int i = 0; i < 100; i++)
            {
                var postId        = provider.AddPost(request);
                var feedProvider  = new NewsfeedProvider();
                var newsFeedEntry = new NewsfeedItem
                {
                    By = request.PostedBy,
                    ReferencePostId = postId,
                    FeedType        = NewsfeedActionType.wallpost,
                    WallOwner       = new NewsfeedWallModel {
                        IsPublic = true, OwnerId = request.PostedBy, WallOwnerType = WallType.user
                    }
                };
                feedProvider.AddNewsfeedItem(newsFeedEntry);
            }
        }
Пример #5
0
        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
            });
        }