Exemple #1
0
        public ViewPost Save(int userId, PostDto postDto)
        {
            var post = new Post()
            {
                UserId = userId
            };

            post = _postRepository.Add(post);

            var text = new Text()
            {
                PostId      = post.Id,
                UserId      = userId,
                Description = postDto.Description
            };

            _textRepository.Add(text);

            var picture = new Picture()
            {
                PostId = post.Id,
                UserId = userId
            };

            if (postDto.Images != null)
            {
                postDto.Images.ForEach(async delegate(string img)
                {
                    var path = await _azureStorageService.UploadFileToBlobAsync("img", img, "image/jpeg");
                    Debug.WriteLine("Resim:" + path);
                    picture.Img = path;
                    _pictureRepository.Add(picture);
                });
            }

            return(GetPost(post.Id));
        }