public async Task <IPagedList <Resource> > GetResource(int page) { string url = "/api/Resource/GetResources"; ApiResponse <List <ResourceDTO> > data = await request.CallApiWithoutAuth <ApiResponse <List <ResourceDTO> > >(url); IEnumerable <ResourceDTO> enumerable = data.Data as IEnumerable <ResourceDTO>; List <Resource> resource = new List <Resource>(); foreach (ResourceDTO re in enumerable) { Resource reso = ResourceMapper.MapToModel(re); resource.Add(reso); } IPagedList <Resource> resources = resource.ToPagedList(page, 4); return(resources); }
public async Task <List <Product> > GetProducts(String type) { String url = "/api/Product/GetProducts/" + type; ApiResponse <List <ProductDTO> > data = await request.CallApiWithoutAuth <ApiResponse <List <ProductDTO> > >(url); if (data.Data != null) { IEnumerable <ProductDTO> enumerable = data.Data as IEnumerable <ProductDTO>; List <Product> selectedProducts = new List <Product>(); foreach (ProductDTO prod in enumerable) { Product product = ProductMapper.MapToModel(prod); selectedProducts.Add(product); } return(selectedProducts); } else { return(null); } }