示例#1
0
        public async Task Update(int postId, PostUpdate update, User user)
        {
            Post?p = await repo.FindById(postId);

            if (p == null)
            {
                throw new NotFoundException($"No post with Id {postId} found.");
            }

            p.Update(update);
            await repo.Update(p);

            await bus.Dispatch(new PostUpdateEvent(p));
        }
示例#2
0
        public void Update(PostUpdate update)
        {
            if (Type == PostType.Link)
            {
                throw new InvalidOperationException();
            }

            if (WasDeleted)
            {
                throw new InvalidOperationException("Post was already deleted");
            }

            WasUpdated = true;
            Body       = update.Body;
        }