Exemplo n.º 1
0
        internal static async Task <Insegnante> findInsegnanteById(int id, string uri)
        {
            Insegnante i           = null;
            var        json        = "{\"id\":" + JsonConvert.SerializeObject(id) + "}";
            var        sendContent = new StringContent(json, Encoding.UTF8, "application/json");

            Console.WriteLine("JSON: " + json);
            try
            {
                HttpResponseMessage response = await _client.PostAsync(uri, sendContent);

                Console.WriteLine(response.StatusCode);
                if (response.IsSuccessStatusCode)
                {
                    string content = await response.Content.ReadAsStringAsync();

                    Console.WriteLine(content);
                    i = JsonConvert.DeserializeObject <Insegnante>(content);
                }
            }
            catch
            {
                Console.WriteLine("Errore");
            }
            return(i);
        }
Exemplo n.º 2
0
 public EditProfilePage(Insegnante insegnante)
 {
     InitializeComponent();
     this.insegnante      = insegnante;
     this.positionAdapter = new PositionAdapter();
     completaCampi();
     this.StL_materie.Children.Add(this.en1_materie);
 }
Exemplo n.º 3
0
 public CorsoModel(Corso corso, Insegnante insegnante)
 {
     Id          = corso.ID;
     Nome        = corso.Nome;
     Descrizione = corso.Descrizione;
     DataInizio  = corso.DataI.ToShortDateString();
     DataFine    = corso.DataF.ToShortDateString();
     Insegnante  = insegnante.Nome + " " + insegnante.Cognome;
 }
Exemplo n.º 4
0
        public ProfilePage2(Insegnante insegnante, String origine)
        {
            InitializeComponent();
            this.btn_salvaRecensione.IsVisible = false;
            this.insegnante = insegnante;
            gestisciVisibilita();
            this.completeProfile();
            this.popolaRecensioni();
            this.origine = origine;
            this.riempiDescrizione();

            //binding
            //this.eval_lbl.Text = insegnante.valutazioneMedia;
        }
Exemplo n.º 5
0
        private async void preferiti_list_ItemTapped(object sender, ItemTappedEventArgs e)
        {
            if (sender is ListView lv)
            {
                lv.SelectedItem = null;
            }
            this.IsEnabled = false;
            RisultatoRicercaInsegnanti r = (RisultatoRicercaInsegnanti)e.Item;
            Insegnante i = await InsegnantiService.getInsegnante(r.id);

            if (i.id != 0)
            {
                await Navigation.PushAsync(new ProfilePage2(i, "preferiti"));
            }
            this.IsEnabled = true;
        }
Exemplo n.º 6
0
        public static async void SaveAsync(Insegnante i, string uri)
        {
            var json        = JsonConvert.SerializeObject(i);
            var sendContent = new StringContent(json, Encoding.UTF8, "application/json");

            Console.WriteLine(json);
            HttpResponseMessage response = null;

            try
            {
                response = await _client.PostAsync(uri, sendContent);
            }
            catch
            {
                Console.WriteLine("errore");
            }
        }
Exemplo n.º 7
0
        internal static async Task <Insegnante> getInsegnante(int id)
        {
            Insegnante i = await InsegnantiRepository.findInsegnanteById(id, Constants.TutoripEndPoint + "/insegnante/findInsegnanteById.php/");

            if (i != null)
            {
                if (i.valutazioneMedia == "0")
                {
                    i.valutazioneMedia = "-";
                }
                else
                {
                    i.valutazioneMedia = ArrotondaStringa(i.valutazioneMedia);
                }
                return(i);
            }
            return(null);
        }
 public async Task Create(ApplicationDbContext db, Insegnante d)
 {
     db.Insegnanti.Add(d);
     await db.SaveChangesAsync();
 }
Exemplo n.º 9
0
        private async void Menu_ItemTapped(object sender, ItemTappedEventArgs e)
        {
            if (sender is ListView lv)
            {
                lv.SelectedItem = null;
            }
            ElementoMenu em = (ElementoMenu)e.Item;

            if (em.testo == "Diventa insegnante")
            {
                /*if (Preferences.Get("isInsegnante", false) == true)
                 *  await Navigation.PushAsync(new ProfilePage2(new Insegnante())); //sarà da mettere l'insegnante corrente
                 * else
                 * {*/
                if (Preferences.Get("id", null) == null)
                {
                    //await Navigation.PushAsync(new AccountPage());
                    Navigation.InsertPageBefore(new AccountPage(), this);
                    await Navigation.PopAsync();
                }
                else
                {
                    Navigation.InsertPageBefore(new EditProfilePage(new Insegnante()), this);
                    await Navigation.PopAsync();
                }
            }

            else if (em.testo == "Profilo insegnante")
            {
                Insegnante i = await InsegnantiService.getInsegnante(int.Parse(Preferences.Get("id", (-1).ToString()))); //occhio al null

                if (i.id != 0)
                {
                    //Navigation.InsertPageBefore(new ProfilePage2(i, "menu"), this);
                    //await Navigation.PopAsync();
                    await Navigation.PushAsync(new ProfilePage2(i, "menu"));
                }
            }

            else if (em.testo == "Insegnanti salvati")
            {
                this.IsEnabled = false;
                //await Navigation.PushAsync(new ProfilePage(new Insegnante()));
                if (Preferences.Get("id", null) != null)
                {
                    RisultatoRicercaInsegnanti[] risultati = await InsegnantiService.getPreferiti(int.Parse(Preferences.Get("id", null))); //eventualmente da spostare nella PreferitiPage

                    Navigation.InsertPageBefore(new PreferitiPage(risultati), this);
                    await Navigation.PopAsync();
                }
                else
                {
                    Navigation.InsertPageBefore(new AccountPage(), this);
                    await Navigation.PopAsync();
                }
                this.IsEnabled = true;
            }

            else if (em.testo == "Accedi o crea il tuo Account")
            {
                Navigation.InsertPageBefore(new AccountPage(), this);
                await Navigation.PopAsync();
            }

            else if (em.testo == "Il tuo account")
            {
                Navigation.InsertPageBefore(new UserAccountPage(), this);
                await Navigation.PopAsync();
            }
            //Navigation.InsertPageBefore(page, this);
            //await Navigation.PopAsync();
        }
Exemplo n.º 10
0
 public static void Save(Insegnante i)
 {
     InsegnantiRepository.SaveAsync(i, Constants.TutoripEndPoint + "/insegnante/create.php/");
 }
Exemplo n.º 11
0
 public ProfilePage(Insegnante item)
 {
     InitializeComponent();
     name_lbl.Text = item.nomeDaVisualizzare;
 }