private async Task <ICollection <EventoDtoOutput> > GetEventi() { ICollection <EventoDtoOutput> listaEventi; EventoClient eventoClient = new EventoClient(await ApiHelper.GetApiClient()); if (SoloPersonali) { listaEventi = await eventoClient.GetEventoCurrentUserAsync(); if (listaEventi != null && listaEventi.Count > 0) { ListHeight = 250 * (listaEventi.Count); } } else { string idCategoria = null; if (Categoria != null) { idCategoria = Categoria.Id.ToString(); } string idUser = null; if (IdUtente.HasValue) { idUser = IdUtente.Value.ToString(); } listaEventi = await eventoClient.GetEventiByidUtenteAsync(CurrentPage, PageSize, idUser, idCategoria); } return(listaEventi); }
async void ToolbarItem_Clicked(System.Object sender, System.EventArgs e) { if (!string.IsNullOrEmpty(entTitoloRegalo.Text) && !string.IsNullOrEmpty(entDescrizioneRegalo.Text) && !string.IsNullOrEmpty(entPrezzoRegalo.Text)) { RegaloInserisciActivityIndicator.IsVisible = true; EventoClient eventoClient = new EventoClient(await ApiHelper.GetApiClient()); RegaloDtoInput regaloDtoInput = new RegaloDtoInput() { Cancellato = viewModel.Item.Cancellato, Descrizione = entDescrizioneRegalo.Text, IdEvento = viewModel.Item.IdEvento, ImmagineRegalo = viewModel.Item.ImmagineRegalo, ImportoCollezionato = viewModel.Item.ImportoCollezionato, Prezzo = int.Parse(entPrezzoRegalo.Text), Titolo = entTitoloRegalo.Text }; //Creo il regalo RegaloDtoOutput regaloInserito = await eventoClient.InserisciRegaloAsync(regaloDtoInput); MessagingCenter.Send(this, "RefreshListaRegaliPersonaliInserisci", "OK"); RegaloInserisciActivityIndicator.IsVisible = false; await Navigation.PopAsync(); } else { await DisplayAlert("Attenzione", "è necessario compilare tutti i campi.", "OK"); } }
private async void Create_Clicked(object sender, EventArgs e) { RegaloInserisciActivityIndicator.IsVisible = true; EventoClient eventoClient = new EventoClient(await ApiHelper.GetApiClient()); RegaloDtoInput regaloDtoInput = new RegaloDtoInput() { Cancellato = viewModel.Item.Cancellato, Descrizione = viewModel.Item.Descrizione, IdEvento = viewModel.Item.IdEvento, ImmagineRegalo = viewModel.Item.ImmagineRegalo, ImportoCollezionato = viewModel.Item.ImportoCollezionato, Prezzo = viewModel.Item.Prezzo, Titolo = viewModel.Item.Titolo }; //Creo il regalo RegaloDtoOutput regaloInserito = await eventoClient.InserisciRegaloAsync(regaloDtoInput); MessagingCenter.Send(this, "RefreshListaRegaliPersonaliInserisci", "OK"); RegaloInserisciActivityIndicator.IsVisible = false; await Navigation.PopModalAsync(); }
private async void Update_Clicked(object sender, EventArgs e) { RegaloModificaActivityIndicator.IsVisible = true; RegaloDtoInput regaloDtoInput = new RegaloDtoInput() { Cancellato = viewModel.Item.Cancellato, Descrizione = viewModel.Item.Descrizione, IdEvento = viewModel.Item.IdEvento, ImmagineRegalo = viewModel.Item.ImmagineRegalo, ImportoCollezionato = viewModel.Item.ImportoCollezionato, Prezzo = viewModel.Item.Prezzo, Titolo = viewModel.Item.Titolo }; Guid id = new Guid(viewModel.Item.Id); //Faccio update del regalo //var regaloAggiornato = EventoClient eventoClient = new EventoClient(await ApiHelper.GetApiClient()); await eventoClient.UpdateRegaloAsync(id, regaloDtoInput); MessagingCenter.Send(this, "RefreshListaRegaliPersonaliModifica", "OK"); RegaloModificaActivityIndicator.IsVisible = false; await DisplayAlert(null, Helpers.TranslateExtension.ResMgr.Value.GetString("RegaloModifica.SalvataggioOk", CurrentCulture.Ci), Helpers.TranslateExtension.ResMgr.Value.GetString("RegaloModifica.Ok", CurrentCulture.Ci)); //TODO APPENA RIPUBBLICO API this.viewModel = new EventoDetailViewModel(eventoInserito); }
private async void Save_Clicked(object sender, EventArgs e) { EventoInserisciActivityIndicator.IsVisible = true; EventoClient eventoClient = new EventoClient(await ApiHelper.GetApiClient()); if (img == null) { EventoCategoria cat = (EventoCategoria)pkCategoria.SelectedItem; img = cat.Immagine; } //Costruisco l'evento EventoDtoInput evento = new EventoDtoInput() { Titolo = entTitolo.Text, Descrizione = edDescrizione.Text, IdCategoriaEvento = ((EventoCategoria)pkCategoria.SelectedItem).Id.Value, DataEvento = dpDataEvento.Date, ImmagineEvento = img }; //Inserisco l'evento EventoDtoOutput eventoInserito = await eventoClient.InserisciEventoAsync(evento); MessagingCenter.Send(this, "RefreshListaEventiPersonaliInsert", "OK"); EventoInserisciActivityIndicator.IsVisible = false; //Torno alla pagina di lista await Navigation.PopAsync(); //Redirect alla modifica dell'evento appena inserito, in questo modo l'utente può aggiungere regali //await Navigation.PushAsync(new EventoModifica(new EventoDetailViewModel(eventoInserito))); }
protected override async void OnAppearing() { base.OnAppearing(); EventoClient eventoClient = new EventoClient(await ApiHelper.GetApiClient()); PartecipazioneDtoOutput partecipazione = await eventoClient.GetPartecipazioniRegaloAsync(new Guid(Regalo.Id)); lvPartecipanti.ItemsSource = partecipazione.UtentiPartecipanti.ToList(); if (partecipazione.NumeroAnonimi.HasValue && partecipazione.NumeroAnonimi.Value > 0) { NumeroPartecipanti.Text = partecipazione.NumeroAnonimi.ToString(); LabelAnonimi.IsVisible = true; } }
private async void Delete_Clicked(object sender, EventArgs e) { try { bool answer = await DisplayAlert("Attenzione", "Vuoi davvero eliminare il regalo?", "Yes", "No"); if (answer) { try { RegaloModificaActivityIndicator.IsVisible = true; EventoClient eventoClient = new EventoClient(await ApiHelper.GetApiClient()); await eventoClient.DeleteRegaloAsync(new Guid(viewModel.Item.Id)); MessagingCenter.Send(this, "RefreshListaRegaliPersonaliModifica", "OK"); await DisplayAlert(null, "Regalo eliminato", "Ok"); var i = Navigation.NavigationStack[Navigation.NavigationStack.Count - 2]; Navigation.RemovePage(i); //var i2 = Navigation.NavigationStack[Navigation.NavigationStack.Count - 1]; //Navigation.RemovePage(i2); //torno indietro alla lista degli eventi personali await Navigation.PopAsync(); } catch { await DisplayAlert(null, "Errore durante l'eliminazione del regalo", "Ok"); } finally { RegaloModificaActivityIndicator.IsVisible = false; } } } catch (Exception) { throw; } }
private async void BtnDona_Clicked(object sender, EventArgs e) { if (String.IsNullOrEmpty(entDonazione.Text)) { await DisplayAlert("Attenzione", "è necessario inserire una cifra valida", "OK"); return; } EventoClient eventoClient = new EventoClient(await ApiHelper.GetApiClient()); await eventoClient.InserisciPartecipazioneRegaloAsync(new Guid(Regalo.Id), double.Parse(entDonazione.Text), chkAnonimo.IsToggled); await DisplayAlert("Complimenti", "la donazione è avvenuta con successo", "OK"); MessagingCenter.Send(this, "RefreshListaRegaliDettaglio", "OK"); await Navigation.PopAsync(); }
async void ToolbarItem_Clicked(System.Object sender, System.EventArgs e) { string action = await DisplayActionSheet(null, "Annulla", "Elimina", "Modifica"); if (action == "Elimina") { bool answer = await DisplayAlert("Attenzione", "Vuoi davvero eliminare il regalo?", "Yes", "No"); if (answer) { try { //RegaloPersonaleDettaglioActivityIndicator.IsVisible = true; EventoClient eventoClient = new EventoClient(await ApiHelper.GetApiClient()); await eventoClient.DeleteRegaloAsync(new Guid(Regalo.Id)); MessagingCenter.Send(this, "RefreshListaRegaliPersonaliElimina", "OK"); await DisplayAlert(null, "Regalo eliminato", "Ok"); //torno indietro alla lista degli eventi personali await Navigation.PopAsync(); await Navigation.PopModalAsync(); } catch { await DisplayAlert(null, "Errore durante l'eliminazione del regalo", "Ok"); } finally { //RegaloPersonaleDettaglioActivityIndicator.IsVisible = false; } } } else if (action == "Modifica") { await Navigation.PushAsync(new RegaloModifica(new RegaloDetailViewModel(Regalo))); } }
/// <summary> /// Restituisce se l'utente si è loggato con facebook,google o email. /// </summary> /// <returns></returns> public static async Task <List <EventoCategoria> > GetCategorie() { List <EventoCategoria> listCategorie = new List <EventoCategoria>(); if (Preferences.Get(CategorieKey, null) != null) { listCategorie = JsonConvert.DeserializeObject <List <EventoCategoria> >(Preferences.Get(CategorieKey, null)); } if (!listCategorie.Any()) { EventoClient eventoClient = new EventoClient(await ApiHelper.GetApiClient()); ICollection <EventoCategoria> categorie = await eventoClient.GetLookupEventoCategoriaAsync(); listCategorie = categorie.ToList(); Preferences.Set(CategorieKey, JsonConvert.SerializeObject(listCategorie)); } return(listCategorie); }
async void TapGestureRecognizer_Tapped(System.Object sender, System.EventArgs e) { if (!(String.IsNullOrEmpty(entTitolo.Text)) && !(String.IsNullOrEmpty(edDescrizione.Text)) && !(String.IsNullOrEmpty(entCategoria.Text)) && !(String.IsNullOrEmpty(entDataEvento.Text))) { EventoInserisciActivityIndicator.IsVisible = true; EventoClient eventoClient = new EventoClient(await ApiHelper.GetApiClient()); if (img == null) { EventoCategoria cat = (EventoCategoria)pkCategoria.SelectedItem; img = cat.Immagine; } //Costruisco l'evento EventoDtoInput evento = new EventoDtoInput() { Titolo = entTitolo.Text, Descrizione = edDescrizione.Text, IdCategoriaEvento = ((EventoCategoria)pkCategoria.SelectedItem).Id.Value, DataEvento = dpDataEvento.Date, ImmagineEvento = img }; //Inserisco l'evento EventoDtoOutput eventoInserito = await eventoClient.InserisciEventoAsync(evento); MessagingCenter.Send(this, "RefreshListaEventiPersonaliInsert", "OK"); EventoInserisciActivityIndicator.IsVisible = false; await DisplayAlert("Nuovo evento inserito", "Inserimento avvenuto con successo", "Ok"); //Torno alla pagina di lista await Navigation.PopAsync(); } else { await DisplayAlert("Campi obbligatori", "Devi valorizzare tutti i campi prima di inserire un nuovo evento", "Ok"); } }
protected async override void OnAppearing() { base.OnAppearing(); MessagingCenter.Subscribe <RegaloDettaglio, string>(this, "RefreshListaRegaliDettaglio", async(sender, arg) => { if (!string.IsNullOrEmpty(arg)) { viewModel.Item.Regali = null; } }); if (viewModel.Item.Regali == null || !viewModel.Item.Regali.Any()) { //RegaliActivityIndicator.IsRunning = true; //RegaliActivityIndicator.IsVisible = true; EventoClient eventoClient = new EventoClient(await ApiHelper.GetApiClient()); var item = await eventoClient.GetEventoByIdAsync(new Guid(viewModel.Item.Id)); viewModel.Item.CodiceCategoriaEvento = item.CodiceCategoriaEvento; // FrameTitle.IsVisible = true; viewModel.Item.Regali = item.Regali; stkActivityIndicator.IsVisible = false; } RegaliDettaglioListView.ItemsSource = viewModel.Item.Regali; //if (eventoDettaglio.Regali != null) //{ // // RegaliDettaglioListView.HeightRequest = ((140) * eventoDettaglio.Regali.Count) + 70; //} //RegaliActivityIndicator.IsRunning = false; //RegaliActivityIndicator.IsVisible = false; }
private async void Delete_Clicked(object sender, EventArgs e) { try { bool answer = await DisplayAlert("Attenzione", "Vuoi davvero eliminare il regalo?", "Yes", "No"); if (answer) { try { EventoClient eventoClient = new EventoClient(await ApiHelper.GetApiClient()); await eventoClient.DeleteRegaloAsync(new Guid(Regalo.Id)); MessagingCenter.Send(this, "RefreshListaRegaliPersonaliElimina", "OK"); await DisplayAlert(null, "Regalo eliminato", "Ok"); //torno indietro alla lista degli eventi personali await Navigation.PopAsync(); await Navigation.PopModalAsync(); } catch { await DisplayAlert(null, "Errore durante l'eliminazione del regalo", "Ok"); } finally { } } } catch (Exception) { throw; } }
async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { Eventi.Clear(); ICollection <EventoDtoOutput> listaEventi; //HttpClient httpClient = new HttpClient(); //httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", Api.ApiHelper.GetToken()); //AmiciClient amiciClient = new AmiciClient(httpClient); //UserInfoDto userInfo = await amiciClient.GetUserInfoByIdUsersAsync(UserId); EventoClient eventoClient = new EventoClient(await Api.ApiHelper.GetApiClient()); listaEventi = await eventoClient.GetEventiByidUtenteAsync(1, 1000, UserId.ToString(), null); foreach (var evento in listaEventi) { Eventi.Add(evento); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
protected override async void OnAppearing() { //Stream stream = new MemoryStream(viewModel.Item.ImmagineEvento); //imgEventoModifica.Source = ImageSource.FromStream(() => { return stream; }); base.OnAppearing(); EventoModificaActivityIndicator.IsVisible = true; if (categorieViewModel.Items == null || categorieViewModel.Items.Count == 0) { await categorieViewModel.LoadCategorie(); pkCategoria.ItemsSource = categorieViewModel.Items; } //if (!isPhotoLoading) //durante il caricamento della foto non si deve ricaricare il viewModel //{ MessagingCenter.Subscribe <RegaloModifica, string>(this, "RefreshListaRegaliPersonaliModifica", async(sender, arg) => { if (!string.IsNullOrEmpty(arg)) { //si potrebbe ricaricare solo la lista dei regali ma x ora ricarichiamo tutto viewModel.Item = null; } }); MessagingCenter.Subscribe <RegaloInserisci, string>(this, "RefreshListaRegaliPersonaliInserisci", async(sender, arg) => { if (!string.IsNullOrEmpty(arg)) { //si potrebbe ricaricare solo la lista dei regali ma x ora ricarichiamo tutto viewModel.Item = null; } }); MessagingCenter.Subscribe <RegaloPersonaleDettaglio, string>(this, "RefreshListaRegaliPersonaliElimina", async(sender, arg) => { if (!string.IsNullOrEmpty(arg)) { //si potrebbe ricaricare solo la lista dei regali ma x ora ricarichiamo tutto viewModel.Item = null; } }); if (this.viewModel.Item == null) { eventoClient = new EventoClient(await ApiHelper.GetApiClient()); this.viewModel = new EventoDetailViewModel(); this.viewModel.Item = await LoadEventoDetailById(); BindingContext = this.viewModel; RegaliModificaListView.ItemsSource = viewModel.Item.Regali; } //EventoModificaActivityIndicator.IsRunning = false; //} EventoCategoria categoria = categorieViewModel.Items.First(a => a.Id == this.viewModel.Item.IdCategoriaEvento); pkCategoria.SelectedItem = categoria; EventoModificaActivityIndicator.IsVisible = false; ScrollViewEventoModifica.IsVisible = true; }