hopefully not a horribly foolish refactoring
This commit is contained in:
parent
59d660165f
commit
1ecaf64dea
82 changed files with 782 additions and 398 deletions
|
@ -0,0 +1,30 @@
|
|||
using Femto.Modules.Blog.Domain.Posts;
|
||||
using MediatR;
|
||||
|
||||
namespace Femto.Modules.Blog.Application.Commands.CreatePost;
|
||||
|
||||
internal class CreatePostCommandHandler(BlogContext context)
|
||||
: IRequestHandler<CreatePostCommand, Guid>
|
||||
{
|
||||
public async Task<Guid> Handle(CreatePostCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var post = new Post(
|
||||
request.AuthorId,
|
||||
request.Content,
|
||||
request
|
||||
.Media.Select(media => new PostMedia(
|
||||
media.MediaId,
|
||||
media.Url,
|
||||
media.Type,
|
||||
media.Order,
|
||||
media.Width,
|
||||
media.Height
|
||||
))
|
||||
.ToList()
|
||||
);
|
||||
|
||||
await context.AddAsync(post, cancellationToken);
|
||||
|
||||
return post.Id;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue