Пример #1
0
        protected async override void OnAppearing()
        {
            base.OnAppearing();

            MessagingCenter.Subscribe <EventoModifica, string>(this, "RefreshListaEventiPersonaliModifica", async(sender, arg) =>
            {
                if (!string.IsNullOrEmpty(arg))
                {
                    viewModel.Items = new ObservableCollection <EventoDtoOutput>();
                }
            });

            MessagingCenter.Subscribe <EventoInserisci, string>(this, "RefreshListaEventiPersonaliInsert", async(sender, arg) =>
            {
                if (!string.IsNullOrEmpty(arg))
                {
                    viewModel.Items = new ObservableCollection <EventoDtoOutput>();
                }
            });

            MessagingCenter.Subscribe <EventoModifica, string>(this, "RefreshListaEventiPersonaliElimina", async(sender, arg) =>
            {
                if (!string.IsNullOrEmpty(arg))
                {
                    viewModel.Items = new ObservableCollection <EventoDtoOutput>();
                }
            });


            //ricarico quando devo recepire le modifiche
            if (viewModel.Items == null || viewModel.Items.Count == 0)
            {
                viewModel.LoadItemsCommand.Execute(null);
            }

            if (amiciPreviewList == null || !amiciPreviewList.Any())
            {
                AmiciClient amiciClient           = new AmiciClient(await ApiHelper.GetApiClient());
                ICollection <UserInfoDto> collect = await amiciClient.GetAmiciCurrentUserPreviewAsync();

                amiciPreviewList = collect.ToList();
                AmiciPreviewListView.ItemsSource = amiciPreviewList;
            }


            await SetUserInfo();
        }