public async Task Handle(AddAuthor message, CancellationToken cancellationToken) { AuthorEntityHandler.Add(message.Author); await Mediator.Send(new SaveChanges()); await Mediator.Publish(new AuthorAdded(message.Author, message.UserId)); }
public async Task Handle(UpdateAuthor message, CancellationToken cancellationToken) { var oldAuthor = await AuthorEntityHandler.Get(message.Author.Id); if (oldAuthor == null) { throw new EntityNotFoundException <Author>(message.Author); } var newAuthor = oldAuthor.Update(message.Author, DateTime.UtcNow); AuthorEntityHandler.Update(newAuthor); await Mediator.Send(new SaveChanges()); await Mediator.Publish(new AuthorUpdated(newAuthor, oldAuthor, message.UserId)); }
public async Task <Author> Handle(GetAuthor request, CancellationToken cancellationToken) => await AuthorEntityHandler.Get(request.Id);
public async Task <IEnumerable <Author> > Handle(GetAuthors request, CancellationToken cancellationToken) => await AuthorEntityHandler.Get();