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); }
public MangaPages(AddMangaPagesDTO addMangaPagesDTO, Manga manga) { Manga = manga; Pages = addMangaPagesDTO.Pages; }
public async Task <MangaPages> Post([FromBody] AddMangaPagesDTO value) { return(await animeService.AddMangaPages(value)); }