public async Task <ResponseDTO <List <OtherVideoDTO> > > GetAllOtherVideosAsync(int page, int max, string type) { var queryableOtherCrawled = dbContext.OtherCrawledVideos.AsQueryable(); int totalCnt = 0; if (type == "All" || type == "all" || type == "ALL") { queryableOtherCrawled = queryableOtherCrawled.OrderByDescending(x => x.order); totalCnt = await queryableOtherCrawled.CountAsync(); } else if (type == "Anime" || type == "anime" || type == "ANIME") { queryableOtherCrawled = queryableOtherCrawled.Where(x => x.Type == "Anime" || x.Type == "anime" || x.Type == "ANIME").OrderByDescending(x => x.order); totalCnt = await queryableOtherCrawled.CountAsync(); } else if (type == "Real" || type == "real" || type == "REAL") { queryableOtherCrawled = queryableOtherCrawled.Where(x => x.Type == "Real" || x.Type == "real" || x.Type == "REAL").OrderByDescending(x => x.order); totalCnt = await queryableOtherCrawled.CountAsync(); } queryableOtherCrawled = queryableOtherCrawled.Skip((page - 1) * max).Take(max); var OtherVideoListRaw = queryableOtherCrawled.ToList(); List <OtherVideoDTO> otherVideosList = OtherVideoListRaw.Select(x => OtherVideoDTO.OtherCrawledVideosToOtherVideoDTO(x)).ToList(); return(new ResponseDTO <List <OtherVideoDTO> > { success = true, data = otherVideosList, currentPage = page, itemsPerPage = max, totalData = totalCnt }); }
public async Task <ResponseDTO <OtherVideoDTO> > GetOtherVideoByIdAsync(long id) { if (id < 1) { return(new ResponseDTO <OtherVideoDTO> { success = false, data = null, responseMessage = "invalid id" }); } OtherCrawledVideos otherVideo = await dbContext.OtherCrawledVideos.FirstOrDefaultAsync(x => x.Id == id); if (otherVideo == null) { return(new ResponseDTO <OtherVideoDTO> { success = false, data = null, responseMessage = "invalid id" }); } return(new ResponseDTO <OtherVideoDTO> { success = true, data = OtherVideoDTO.OtherCrawledVideosToOtherVideoDTO(otherVideo) }); }