Exemplo n.º 1
0
            public async Task <Response> Handle(Request request, CancellationToken cancellationToken)
            {
                var post = await BlogHelpers.GetBlog(_context, request.Id);

                post.Delete();
                _context.Blogs.Update(post);
                await _context.SaveChangesAsync();

                return(await Task.FromResult(new Response { Id = post.Id }));
            }
Exemplo n.º 2
0
            public async Task <Response> Handle(Request request, CancellationToken cancellationToken)
            {
                var post = await BlogHelpers.GetBlog(_context, request.Id);

                var response = new Response
                {
                    Id        = post.Id,
                    Title     = post.Title,
                    Text      = post.Text,
                    CreatedOn = post.CreatedOn
                };

                return(await Task.FromResult(response));
            }
Exemplo n.º 3
0
            public async Task <Response> Handle(Request request, CancellationToken cancellationToken)
            {
                var post = await BlogHelpers.GetBlog(_context, request.Id);

                var relatedPost = await BlogHelpers.GetBlog(_context, request.RelatedPostId);

                post.AddRelated(relatedPost);
                relatedPost.AddRelated(post);

                _context.Update(post);
                _context.Update(relatedPost);
                await _context.SaveChangesAsync();

                return(await Task.FromResult(new Response()));
            }