Ejemplo n.º 1
0
        public async Task <IActionResult> GetAuthor(int id)
        {
            var authorDb = await _authorsRepository.GetAsync(id);

            if (authorDb == null)
            {
                return(NotFound("Autor não encontrado."));
            }

            return(Ok(authorDb.ToAuthorApi()));
        }
Ejemplo n.º 2
0
        public async Task <Comic> ToComic(ComicUpload comicUpload)
        {
            var comic = new Comic(comicUpload);

            comic.Publisher = await _publishersRepository.GetAsync(comicUpload.SelectedPublisher);

            comicUpload.SelectedCategories.ForEach(async ci =>
            {
                var category = await _categoriesRepository.GetAsync(ci);
                comic.IncludeCategory(category);
            });

            comicUpload.SelectedAuthors.ForEach(async ai =>
            {
                var author = await _authorsRepository.GetAsync(ai);
                comic.IncludeAuthor(author);
            });

            comicUpload.SelectedDesigners.ForEach(async di =>
            {
                var designer = await _designersRepository.GetAsync(di);
                comic.IncludeDesigner(designer);
            });

            return(comic);
        }