public async Task EliminaButton(DatiEvento eventoDeclinato)
        {
            REST <Object, bool> connessione = new REST <Object, bool>();

            eventoDeclinato.confermato     = false;
            eventoDeclinato.eliminato      = true;
            eventoDeclinato.organizzazione = user.organizzazione;
            eventoDeclinato.immagine       = null;
            eventoDeclinato.Immagine       = null;
            IsBusy = true;
            bool esito = await connessione.PostJson(URL.ConfermaElimina, eventoDeclinato);

            if (esito)
            {
                if (eventoDeclinato.tipo == "1")
                {
                    await App.Current.MainPage.DisplayAlert("Attenzione", "L'evento è stato declinato", "Ok");
                }
                else
                {
                    await App.Current.MainPage.DisplayAlert("Attenzione", "La nota è stata eliminata", "Ok");
                }
            }
            else
            {
                await App.Current.MainPage.DisplayAlert("Attenzione", "Connessione non riuscita, riprovare", "Ok");
            }
            ListaEventi.Clear();
            ListaNote.Clear();
            GroupDatiEvento.Clear();
            leggiDati();
            IsBusy = false;
        }
        public async void leggiDati()
        {
            REST <Object, DatiEvento> connessione = new REST <Object, DatiEvento>();
            List <DatiEvento>         List        = new List <DatiEvento>();
            var medico = LoginData.getUser();

            user.username  = medico[0].username;
            user.token     = medico[0].token;
            user.eliminato = "true";

            try
            {
                List = await connessione.PostJsonList(URL.Eventi, user);

                if (List.Count != 0)
                {
                    foreach (var i in List)
                    {
                        string img = "";
                        if (i.immagine.Contains("jpeg;"))
                        {
                            img = i.immagine.Substring(23);
                        }
                        else
                        {
                            img = i.immagine.Substring(22);
                        }
                        immagine = Xamarin.Forms.ImageSource.FromStream(
                            () => new MemoryStream(Convert.FromBase64String(img)));
                        i.Immagine = immagine;
                        if (i.confermato == true)
                        {
                            i.TestoButtonEliminato = "ELIMINA";
                        }

                        listaEventiSeguito.Add(i);
                    }
                    ListaEventiSeguito = listaEventiSeguito;
                    IsBusy             = false;
                }
                else
                {
                    DatiEvento x = new DatiEvento();
                    x.titolo       = "Nessun evento disponibile \n Scorri in basso per aggiornare";
                    x.VisibleError = "false";
                    listaEventiSeguito.Add(x);
                }
                ListaEventiSeguito = listaEventiSeguito;
                IsBusy             = false;
            }
            catch (Exception a)
            {
                DatiEvento x = new DatiEvento();
                x.titolo       = "Nessun evento disponibile \n Scorri in basso per aggiornare";
                x.VisibleError = "false";
                listaEventiSeguito.Add(x);
                ListaEventiSeguito = listaEventiSeguito;
                IsBusy             = false;
            }
        }
        public async Task ConfermaButton(DatiEvento eventoConfermato)
        {
            REST <Object, bool> connessione = new REST <Object, bool>();

            eventoConfermato.confermato     = true;
            eventoConfermato.eliminato      = false;
            eventoConfermato.organizzazione = user.organizzazione;
            eventoConfermato.immagine       = null;
            eventoConfermato.Immagine       = null;
            var medico = LoginData.getUser();

            IsBusy = true;
            bool esito = await connessione.PostJson(URL.ConfermaElimina, eventoConfermato);

            if (esito == true)
            {
                await App.Current.MainPage.DisplayAlert("CONFERMA", "Complimenti la partecipazione è andata a buon fine", "Ok");
            }
            else
            {
                await App.Current.MainPage.DisplayAlert("Attenzione", "Connessione non riuscita riprovare", "Ok");
            }
            ListaEventi.Clear();
            ListaNote.Clear();
            GroupDatiEvento.Clear();
            leggiDati();
            IsBusy = false;
        }
        public void displayButtons(DatiEvento x)
        {
            dettagli = x;
            if (dettagli.VisibleError != "false")
            {
                foreach (var i in listaEventiSeguito)
                {
                    if (i == x)
                    {
                        if (i.confermato != true)
                        {
                            i.Visible = "true";
                        }

                        i.VisibileInfo = "true";
                    }
                    else
                    {
                        i.VisibileInfo = "false";
                        i.Visible      = "false";
                    }
                }
                ListaEventiSeguito = listaEventiSeguito;
            }
        }
        public async Task <bool> EliminaButton(DatiEvento x)
        {
            REST <Object, bool> connessione = new REST <Object, bool>();

            x.confermato = false;
            x.eliminato  = true;
            x.immagine   = null;
            x.Immagine   = null;
            bool esito = await connessione.PostJson(URL.ConfermaElimina, x);

            return(esito);
        }
 public VisualizzaEventiInDettaglioModelView(DatiEvento evento)
 {
     this.dettagliEvento = evento;
     if (dettagliEvento.tipo == "1")
     {
         VisiblePartecipo = true;
     }
     else
     {
         VisiblePartecipo = false;
     }
     inserimentoDati();
 }
示例#7
0
 public IActionResult Post(Evento item)
 {
     if (ModelState.IsValid)
     {
         var entity = new DatiEvento()
         {
             Id          = item.Id,
             Nome        = item.Nome,
             Localita    = item.Localita,
             Data        = item.Data,
             Descrizione = item.Descrizione,
             Note        = item.Note
         };
         this.db.Add(entity);
         this.db.SaveChanges();
         item.Id = entity.Id;
         return(CreatedAtAction(nameof(Get), new { id = entity.Id }, item));
     }
     return(BadRequest(ModelState));
 }
 private void ListEventi_OnItemTapped(object sender, ItemTappedEventArgs e)
 {
     evento = e.Item as DatiEvento;
     z.displayButtons(evento);
 }
        public async void displayButtons(DatiEvento eventoSelezionato)
        {
            dettagli  = eventoSelezionato;
            urlScelto = eventoSelezionato.url_evento;
            if (dettagli.VisibleError != "false")
            {
                foreach (var i in listaEventi)
                {
                    if (i == eventoSelezionato)
                    {
                        if (i.confermato != true)
                        {
                            if (urlScelto != null)
                            {
                                var actionSheet = await App.Current.MainPage.DisplayActionSheet("Attenzione", "Cancel", null, "Partecipa", "Declina", "Dettagli", "Sito web");

                                switch (actionSheet)
                                {
                                case "Partecipa":
                                    await ConfermaButton(eventoSelezionato);

                                    break;

                                case "Declina":
                                    await EliminaButton(eventoSelezionato);

                                    break;

                                case "Dettagli":
                                    await App.Current.MainPage.Navigation.PushAsync(new VisualizzaEventoInDettaglio(dettaglio()));

                                    break;

                                case "Sito web":
                                    VaiPaginaWeb();
                                    break;

                                case "Cancel":
                                    break;
                                }
                                return;
                            }
                            else
                            {
                                var actionSheet = await App.Current.MainPage.DisplayActionSheet("Attenzione", "Cancel", null, "Partecipa", "Declina", "Dettagli");

                                switch (actionSheet)
                                {
                                case "Partecipa":
                                    await ConfermaButton(eventoSelezionato);

                                    break;

                                case "Declina":
                                    await EliminaButton(eventoSelezionato);

                                    break;

                                case "Dettagli":
                                    await App.Current.MainPage.Navigation.PushAsync(new VisualizzaEventoInDettaglio(dettaglio()));

                                    break;

                                case "Cancel":
                                    break;
                                }
                                return;
                            }
                        }
                        else
                        {
                            var actionSheet = await App.Current.MainPage.DisplayActionSheet("Attenzione", "Cancel", null, "Declina", "Dettagli", "Sito web");

                            switch (actionSheet)
                            {
                            case "Declina":
                                await EliminaButton(eventoSelezionato);

                                break;

                            case "Dettagli":
                                await App.Current.MainPage.Navigation.PushAsync(new VisualizzaEventoInDettaglio(dettaglio()));

                                break;

                            case "Sito web":
                                VaiPaginaWeb();
                                break;

                            case "Cancel":
                                break;
                            }
                            return;
                        }
                    }
                }
                //ListaEventi = listaEventi;
                //GroupDatiEvento = groupDatiEvento;
            }
            if (dettagli.VisibleError != "false")
            {
                foreach (var i in listaNote)
                {
                    if (i == eventoSelezionato)
                    {
                        if (i.confermato != true)
                        {
                            if (urlScelto != null)
                            {
                                var actionSheet = await App.Current.MainPage.DisplayActionSheet("Attenzione", "Cancel", null, "Dettagli", "Sito web");

                                switch (actionSheet)
                                {
                                case "Dettagli":
                                    await App.Current.MainPage.Navigation.PushAsync(new VisualizzaEventoInDettaglio(dettaglio()));

                                    break;

                                case "Sito web":
                                    VaiPaginaWeb();
                                    break;

                                case "Cancel":
                                    break;
                                }
                                return;
                            }
                            else
                            {
                                var actionSheet = await App.Current.MainPage.DisplayActionSheet("Attenzione", "Cancel", null, "Dettagli");

                                switch (actionSheet)
                                {
                                case "Dettagli":
                                    await App.Current.MainPage.Navigation.PushAsync(new VisualizzaEventoInDettaglio(dettaglio()));

                                    break;

                                case "Cancel":
                                    break;
                                }
                                return;
                            }
                        }
                        else
                        {
                            var actionSheet = await App.Current.MainPage.DisplayActionSheet("Attenzione", "Cancel", null, "Dettagli");

                            switch (actionSheet)
                            {
                            case "Dettagli":
                                await App.Current.MainPage.Navigation.PushAsync(new VisualizzaEventoInDettaglio(dettaglio()));

                                break;

                            case "Cancel":
                                break;
                            }
                            return;
                        }
                    }
                }
                //ListaEventi = listaEventi;
                //GroupDatiEvento = groupDatiEvento;
            }
        }
        /*Effettua la connessione per ricevere i dati dal server*/
        public async void leggiDati()
        {
            IsVoidEvent = false;
            ObservableCollection <GroupDatiEvento> groupList = new ObservableCollection <GroupDatiEvento>();
            REST <Object, DatiEvento> connessione            = new REST <Object, DatiEvento>();
            List <DatiEvento>         List = new List <DatiEvento>();
            var medico = LoginData.getUser();

            foreach (var i in medico)
            {
                if (i.attivo)
                {
                    user.username       = i.username;
                    user.token          = i.token;
                    user.organizzazione = i.organizzazione;
                    user.eliminato      = "false";
                }
            }
            if (string.IsNullOrEmpty(user.username))
            {
                user.username       = medico[0].username;
                user.password       = medico[0].password;
                user.token          = medico[0].token;
                user.organizzazione = medico[0].organizzazione;
                user.eliminato      = "false";
            }
            if (CrossConnectivity.Current.IsConnected)
            {
                List = await connessione.PostJsonList(URL.Eventi, user);

                if (List == null)
                {
                    NessunEvento = "Nessun evento disponibile \n Scorri in basso per aggiornare";
                    IsVoidEvent  = true;
                }
                else
                {
                    if (List.Count != 0)
                    {
                        foreach (var i in List)
                        {
                            CultureInfo culture = new CultureInfo(cultureName);
                            formaDateTime      = Convert.ToDateTime(i.data, culture);
                            i.data             = formaDateTime.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
                            i.data_ordinamento = formaDateTime;
                            i.dat_fine         = i.data_fine.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);


                            string img = "";
                            try
                            {
                                if (!String.IsNullOrEmpty(i.immagine))
                                {
                                    if (i.immagine.Contains("jpeg;"))
                                    {
                                        img = i.immagine.Substring(23);
                                    }
                                    else
                                    {
                                        img = i.immagine.Substring(22);
                                    }

                                    immagine = Xamarin.Forms.ImageSource.FromStream(
                                        () => new MemoryStream(Convert.FromBase64String(img)));
                                    i.Immagine = immagine;
                                }
                            }
                            catch (Exception e)
                            {
                                i.Immagine = "";
                            }

                            if (i.confermato == true)
                            {
                                i.TestoButtonEliminato = "ELIMINA";
                            }

                            if (i.tipo == "1")
                            {
                                listaEventi.Add(i);
                            }

                            else if (i.tipo == "2")
                            {
                                listaNote.Add(i);
                            }
                        }

                        ListaEventi = ListaEventi.OrderByDescending(o => o.data_ordinamento).ToList();
                        GroupDatiEvento cGroupListEventi = new GroupDatiEvento(listaEventi);
                        cGroupListEventi.Heading = "Eventi";
                        groupList.Add(cGroupListEventi);


                        listaNote = listaNote.OrderByDescending(o => o.data_ordinamento).ToList();
                        GroupDatiEvento cGroupListNote = new GroupDatiEvento(listaNote);
                        cGroupListNote.Heading = "Note";

                        groupList.Add(cGroupListNote);
                        //ListaEventi = listaEventi;
                        GroupDatiEvento = groupList;

                        IsBusy = false;
                    }
                    else
                    {
                        DatiEvento evento = new DatiEvento();
                        evento.titolo       = "Nessun evento disponibile \n Scorri in basso per aggiornare";
                        IsVoidEvent         = true;
                        NessunEvento        = "Nessun evento disponibile \n Scorri in basso per aggiornare";
                        evento.VisibleError = "false";
                        listaEventi.Add(evento);
                        listaNote.Add(evento);
                    }

                    //ListaEventi = listaEventi;
                    GroupDatiEvento = groupList;
                    IsBusy          = false;
                }
            }
            else
            {
                DatiEvento evento = new DatiEvento();
                evento.titolo       = "Nessun evento \n Scorri in basso per aggiornare";
                evento.VisibleError = "false";
                IsVoidEvent         = true;
                NessunEvento        = "Nessun evento \n Scorri in basso per aggiornare";
                listaEventi.Add(evento);
                listaNote.Add(evento);
                //ListaEventi = listaEventi;
                GroupDatiEvento = groupList;
                IsBusy          = false;
            }
        }
 public VisualizzaEventoInDettaglio(DatiEvento x)
 {
     InitializeComponent();
     evento         = x;
     BindingContext = new ModelViews.VisualizzaEventiInDettaglioModelView(evento);
 }
示例#12
0
 public void displayButtons(DatiEvento x)
 {
     if (x.VisibleError != "false")
     {
         foreach (var i in listaEventi)
         {
             if (i == x)
             {
                 if (i.confermato != true)
                 {
                     if (x.url_evento != null)
                     {
                         i.Visible           = "true";
                         i.VisibileInfo      = "true";
                         i.VisibileInSeguito = "true";
                         i.VisibleWeb        = "true";
                     }
                     else
                     {
                         i.Visible           = "true";
                         i.VisibileInfo      = "true";
                         i.VisibileInSeguito = "true";
                         i.VisibleWeb        = "false";
                     }
                 }
                 else
                 {
                     i.VisibileInfo      = "true";
                     i.VisibileInSeguito = "true";
                 }
             }
             else
             {
                 i.VisibileInfo      = "false";
                 i.Visible           = "false";
                 i.VisibileInSeguito = "false";
                 i.VisibleWeb        = "false";
             }
         }
         //ListaEventi = listaEventi;
         //GroupDatiEvento = groupDatiEvento;
     }
     if (x.VisibleError != "false")
     {
         foreach (var i in listaNote)
         {
             if (i == x)
             {
                 if (i.confermato != true)
                 {
                     if (x.url_evento != null)
                     {
                         i.Visible           = "false";
                         i.VisibileInfo      = "true";
                         i.VisibileInSeguito = "false";
                         i.VisibleWeb        = "true";
                     }
                     else
                     {
                         i.Visible           = "false";
                         i.VisibileInfo      = "true";
                         i.VisibileInSeguito = "false";
                         i.VisibleWeb        = "false";
                     }
                 }
                 else
                 {
                     i.VisibileInfo      = "true";
                     i.VisibileInSeguito = "false";
                 }
             }
             else
             {
                 i.VisibileInfo      = "false";
                 i.Visible           = "false";
                 i.VisibileInSeguito = "false";
                 i.VisibleWeb        = "false";
             }
         }
         //ListaEventi = listaEventi;
         GroupDatiEvento = groupDatiEvento;
     }
 }
示例#13
0
        /*Effettua la connessione per ricevere i dati dal server*/
        public async void leggiDati()
        {
            IsBusy = true;
            ObservableCollection <GroupDatiEvento> groupList = new ObservableCollection <GroupDatiEvento>();
            REST <Object, DatiEvento> connessione            = new REST <Object, DatiEvento>();
            var    use  = LoginData.getUser();
            Utente user = new Utente();

            user.username       = use[0].username;
            user.password       = use[0].password;
            user.organizzazione = use[0].organizzazione;
            user.token          = use[0].token;
            user.eliminato      = "false";
            try
            {
                var list = await connessione.PostJsonList(URL.Eventi, user);

                if (list.Count != 0)
                {
                    foreach (var i in list)
                    {
                        CultureInfo culture       = new CultureInfo(cultureName);
                        var         formaDateTime = Convert.ToDateTime(i.data, culture);
                        i.data = formaDateTime.ToString().Substring(0, 10);
                        if (i.confermato == true)
                        {
                            i.TestoButtonEliminato = "ELIMINA";
                        }

                        if (i.tipo == "1")
                        {
                            listaEventi.Add(i);
                        }
                        else if (i.tipo == "2")
                        {
                            listaNote.Add(i);
                        }
                    }
                    GroupDatiEvento cGroupListEventi = new GroupDatiEvento(listaEventi);
                    cGroupListEventi.Heading = "Eventi";
                    groupList.Add(cGroupListEventi);
                    GroupDatiEvento cGroupListNote = new GroupDatiEvento(listaNote);
                    cGroupListNote.Heading = "Note";
                    groupList.Add(cGroupListNote);
                    IsBusy = false;
                }
                else
                {
                    DatiEvento x = new DatiEvento();
                    x.titolo       = "Nessun evento disponibile \n Scorri in basso per aggiornare";
                    NessunEvento   = "Nessun evento disponibile \n Scorri in basso per aggiornare";
                    x.VisibleError = "false";
                    listaEventi.Add(x);
                    listaNote.Add(x);
                    IsBusy = false;
                }
                GroupDatiEvento = groupList;
            }
            catch (Exception a)
            {
                DatiEvento x = new DatiEvento();
                x.titolo       = "Nessun evento disponibile \n Scorri in basso per aggiornare";
                x.VisibleError = "false";
                NessunEvento   = "Nessun evento disponibile \n Scorri in basso per aggiornare";
                listaEventi.Add(x);
                listaNote.Add(x);
                //ListaEventi = listaEventi;
                GroupDatiEvento = groupList;
                IsBusy          = false;
            }
        }