Ejemplo n.º 1
0
        private async Task LoadMyPetsAsync(bool isRefresh = false)
        {
            if (isRefresh)
            {
                IsRefreshing = true;
            }
            else
            {
                IsBusy = true;
            }

            IEnumerable <PetDto> pets;

            if (KutyAppClientContext.IsLoggedIn)
            {
                pets = await EnvironmentApi.GetMyPetsAsync();
            }
            else
            {
                pets = await PetRepository.GetMyPetsAsync();
            }

            //TODO: ures listanal a parallel elszal
            if (pets.Any())
            {
                Pets = new ObservableCollection <PetsListItemViewModel>(pets.Select(p => new PetsListItemViewModel(EnvironmentApi, KutyAppClientContext, p)));

                if (isRefresh)
                {
                    IsRefreshing = false;
                }
                else
                {
                    IsBusy = false;
                }
                await Pets.ParallelForEachAsync(async p => await p.LoadImageAsync(), maxDegreeOfParalellism : 4);
            }

            if (isRefresh)
            {
                IsRefreshing = false;
            }
            else
            {
                IsBusy = false;
            }
        }