public Post CreatePost(CreatePostDto postDto, User user) { string postId = Guid.NewGuid().ToString(); string imgUrl = null; try { imgUrl = postDto.Image == null ? null : _s3Uploader.UploadFile(postDto.Image, postId); Post post = new Post() { Content = postDto.Content, CreatedOn = DateTime.UtcNow, PostId = postId, Visability = postDto.WhoIsWatching, ImgUrl = imgUrl }; _postsRepository.Create(post, user.UserId); foreach (var reference in postDto.Referencing) { _postsRepository.CreateReference(postId, reference.UserId, reference.StartIndex, reference.EndIndex); if (user.UserId != reference.UserId) { object referencigNoification = new { user, postId, ReciverId = reference.UserId }; _serverComunication.NotifyUser("/ReferenceInPost", referencigNoification); } } return(post); } catch (Exception e) { _log.Error(e); return(null); } }