Пример #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 <PhoneCongregation> > LoadPhoneCongregations()
        {
            try
            {
                var phoneService = new PhoneCongregationService();
                List <PhoneCongregation> phones = new List <PhoneCongregation>();

                phones = phoneService.GetAllPhonesFromRealm().ToList();

                if (!phones.Any())
                {
                    phones = await phoneService.GetAllPhonesFromApi();
                }

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