// get magazineIds by each category public static async Task <MagazineIdsByCategory> GetMagazineIdByCategoryAsync(string token, string category, ApiService service, CancellationToken cancelToken) { var magazineResponse = await service.GetMagazineByCategoryByApiAsync(token, category, cancelToken); return(magazineResponse.Data.GroupBy(x => x.Category).Select(x => new MagazineIdsByCategory { Name = x.Key, Ids = x.Select(z => z.Id).ToList() }).FirstOrDefault()); }
// get magazine Id by categories after getting categories from categories api call public static async Task <List <MagazineIdsByCategory> > GetMagazineIdsByCategoriesAsync(string token, List <string> categories, ApiService service, CancellationToken cancelToken) { var magazineIdsByCategories = categories.Select(async s => await GetMagazineIdByCategoryAsync(token, s, service, cancelToken)).ToList(); return((await Task.WhenAll(magazineIdsByCategories)).ToList()); }