コード例 #1
0
        private void ExecuteRefreshListCommand()
        {
            IsRefreshing = true;
            var collaboratorService      = new CollaboratorService();
            var phoneCongregationService = new PhoneCongregationService();
            var usefulPhoneService       = new UsefulPhoneService();

            Task.Run(async() =>
            {
                try
                {
                    UserDialogs.Instance.ShowLoading(AppSettings.WaitingText, MaskType.Black);
                    collaboratorService.CleanCollaborators();
                    usefulPhoneService.CleanUsefulPhones();
                    phoneCongregationService.CleanPhoneCongregations();
                    Collaborators      = new List <Collaborator>(await collaboratorService.GetAllCollaboratorsFromApi());
                    UsefulPhones       = new List <UsefulPhone>(await usefulPhoneService.GetAllUsefulPhonesFromApi());
                    PhoneCongregations = new List <PhoneCongregation>(await phoneCongregationService.GetAllPhonesFromApi());
                    CollaboratorsList  = ListCollaborator(string.Empty);
                    RaisePropertyChanged(nameof(Collaborators));
                    RaisePropertyChanged(nameof(UsefulPhones));
                    RaisePropertyChanged(nameof(PhoneCongregations));
                    SearchText = string.Empty;
                    UserDialogs.Instance.HideLoading();
                    DefaultToasts.Success("Dados atualizados com sucesso.");
                    IsRefreshing = false;
                }
                catch (Exception ex)
                {
                    DefaultToasts.Error(ex.Message);
                    UserDialogs.Instance.HideLoading();
                    IsRefreshing = false;
                }
            });
        }
コード例 #2
0
        private async Task <IList <UsefulPhone> > LoadUsefulPhones()
        {
            try
            {
                var usefulPhoneService    = new UsefulPhoneService();
                List <UsefulPhone> phones = new List <UsefulPhone>();

                phones = usefulPhoneService.GetAllUsefulPhonesFromRealm().ToList();

                if (!phones.Any())
                {
                    phones = await usefulPhoneService.GetAllUsefulPhonesFromApi();
                }

                return(phones);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }