Exemplo n.º 1
0
        public async Task Handle(BookAuthorNameChanged @event)
        {
            var oldAuthor = await authorFacade.GetById(@event.OldAuthorId);

            oldAuthor.BookTitles.Remove(@event.BookTitle);
            await authorFacade.Update(oldAuthor);

            logger.LogInformation($"{oldAuthor.Name} titles updated. {@event.BookTitle} removed.");

            var newAuthor = await authorFacade.GetById(@event.NewAuthorId);

            if (newAuthor.BookTitles == null)
            {
                newAuthor.BookTitles = new List <string>();
            }

            newAuthor.BookTitles.Add(@event.BookTitle);
            await authorFacade.Update(newAuthor);

            logger.LogInformation($"{newAuthor.Name} titles updated. {@event.BookTitle} added.");
        }
Exemplo n.º 2
0
 public async Task OnGet()
 {
     AuthorDto = await authorFacade.GetById(Request.Query.FirstOrDefault(a => a.Key == "id").Value);
 }