コード例 #1
0
        public async Task Save(NewPostData newPost)
        {
            var url = await cloudStorageService.SaveFile(newPost.Image, CONTAINER_NAME);

            await postRepository.SaveAsync(new Post
            {
                Image   = new Image(url),
                Message = newPost.Message,
                Author  = userService.GetLoggedUser()
            });
        }
コード例 #2
0
        public async Task <ActionResult> Save(NewPostData newPost)
        {
            try
            {
                await postService.Save(newPost);
            }
            catch (Exception ex)
            {
                return(BadRequest(Json(ex)));
            }

            return(Ok(Json("OK")));
        }
コード例 #3
0
        public async Task WhenPostingToChannel_ItShouldIssuePostFileCommand()
        {
            var timestamp = DateTime.UtcNow;

            this.timestampCreator.Setup(v => v.Now()).Returns(timestamp);

            var data    = new NewPostData(ChannelId, FileId, null, null, null, QueueId, 0, 0, 0, 0, 0, null);
            var command = new PostToChannelCommand(Requester, PostId, ChannelId, FileId, null, null, 0, 0, 0, 0, 0, new List <FileId>(), null, QueueId, timestamp);

            this.requesterContext.Setup(_ => _.GetRequesterAsync()).ReturnsAsync(Requester);
            this.guidCreator.Setup(_ => _.CreateSqlSequential()).Returns(PostId.Value);
            this.postToChannel.Setup(v => v.HandleAsync(command)).Returns(Task.FromResult(0)).Verifiable();

            await this.target.PostPost(data);

            this.postToChannel.Verify();
        }