Exemplo n.º 1
0
        public async Task <MangaPages> AddMangaPages(AddMangaPagesDTO addMangaPagesDTO)
        {
            //foreach (Page page in addMangaPagesDTO.Pages)
            //{
            //    db.Pages.Add(page);
            //}
            MangaPages isExistMangaPages = await db.MangaPages.FirstOrDefaultAsync(mangaPages =>
                                                                                   mangaPages.Manga.Id == addMangaPagesDTO.MangaId);

            if (isExistMangaPages != null)
            {
                return(null);
            }

            Manga manga = await db.Mangas.FirstOrDefaultAsync(findManga => addMangaPagesDTO.MangaId == findManga.Id);

            MangaPages addMangaPages = new MangaPages(addMangaPagesDTO, manga);
            await db.MangaPages.AddAsync(addMangaPages);

            int countChanges = await db.SaveChangesAsync();

            if (countChanges < 0)
            {
                return(null);
            }
            return(addMangaPages);
        }
Exemplo n.º 2
0
 public MangaPages(AddMangaPagesDTO addMangaPagesDTO, Manga manga)
 {
     Manga = manga;
     Pages = addMangaPagesDTO.Pages;
 }
Exemplo n.º 3
0
 public async Task <MangaPages> Post([FromBody] AddMangaPagesDTO value)
 {
     return(await animeService.AddMangaPages(value));
 }