示例#1
0
        public async Task <IActionResult> OnPost()
        {
            AuthorDto.Name    = Request.Form["name"];
            AuthorDto.Surname = Request.Form["surname"];

            await authorFacade.Update(AuthorDto);

            logger.LogInformation("Author updated");
            return(RedirectToPage("/Authors"));
        }
示例#2
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.");
        }
        public async Task Handle(BookTitleChanged @event)
        {
            List <AuthorDetailDTO> affectedAuthors = await authorFacade.GetAuthorsByBookAsync(@event.OldTitle);

            foreach (var author in affectedAuthors)
            {
                author.BookTitles.Remove(@event.OldTitle);
                author.BookTitles.Add(@event.NewTitle);
                await authorFacade.Update(author);
            }

            await libraryRecordFacade.UpdateLibraryRecordsWithNewBookTitleAsync(@event.BookId, @event.NewTitle);
        }