Ejemplo n.º 1
0
        async void OnFindSimilarClicked(object sender, EventArgs args)
        {
            this.VisibleSpinner();
            MobileServiceClient client   = new MobileServiceClient(Constants.ApplicationURL);
            HttpContent         content  = new ByteArrayContent(immagine);
            HttpResponseMessage response = await client.InvokeApiAsync("Emotize/FaceMatch", content, HttpMethod.Post, null, null);

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                string json = await response.Content.ReadAsStringAsync();

                Profilo profilo = JsonConvert.DeserializeObject <Profilo>(json);
                this.InvisibleSpinner();
                Application.Current.MainPage = new FaceMatchResultPage(profilo);
            }
            else
            {
                if (response.StatusCode == System.Net.HttpStatusCode.NoContent)
                {
                    this.InvisibleSpinner();
                    Application.Current.MainPage = new FaceMatchResultPage(null);
                }
                else
                {
                    this.InvisibleSpinner();
                    await DisplayAlert("Attenzione", "Comunicazione col server fallita", "OK");

                    App.Current.MainPage = new HomePage();
                }
            }
        }
        public ActionResult Profile()
        {
            SetPageTitle("Profilo");

            User        bo  = new User();
            Anagrafiche boA = new Anagrafiche();

            UserModel ut = GetUserFromSession(HttpContext.Session);

            Profilo ret = bo.GetProfilo(ut.Utente.ID);

            Strumento[] strumenti = boA.GetListaStrumenti();

            ProfiloStrumento[] profiloStrumenti = bo.GetStrumentiCollegati(ret.IDUtente);

            int[] strumentiCollegati = Array.ConvertAll(profiloStrumenti, x => x.IDStrumento);

            ProfiloModel dati = new ProfiloModel
            {
                Utente             = ut.Utente,
                Profilo            = ret,
                Strumenti          = strumenti,
                StrumentiCollegati = strumentiCollegati
            };

            return(View("Profile", dati));
        }
Ejemplo n.º 3
0
        public Profilo GetProfilo(int userID)
        {
            Profilo profilo = null;

            if (dao.Connected)
            {
                profilo = Users.GetProfilo(dao, userID);
            }
            return(profilo);
        }
Ejemplo n.º 4
0
        internal void SetParameters(string nome, string indirizzo, string email, string telefono, string disdetta, string scontoClienteRegistrato, string scontoPrenPeriodica)
        {
            Profilo        profilo  = new Profilo(nome, indirizzo, telefono, email);
            PoliticaCentro politica = new PoliticaCentro(Convert.ToSingle(scontoClienteRegistrato) / 100, Convert.ToSingle(scontoPrenPeriodica) / 100, Convert.ToInt32(disdetta));
            DialogResult   result   = DialogResult.No;

            result = MessageBox.Show("Vuoi salvare le modifiche?", "Conferma Modifiche", MessageBoxButtons.YesNo);
            if (result == DialogResult.Yes)
            {
                CentroSaleProve.GetIstance().Profilo  = profilo;
                CentroSaleProve.GetIstance().Politica = politica;
                MessageBox.Show("Modifiche salvate con successo!");
            }
        }
Ejemplo n.º 5
0
        async void OnLogoutClicked(object sender, EventArgs args)
        {
            var answer = await DisplayAlert("Logout", "Eseguire il logout?", "Sì", "Annulla");

            if (answer)
            {
                profilo = null;
                App.Current.MainPage = new IntroPage();
            }
            else
            {
                return;
            }
        }
Ejemplo n.º 6
0
 public FaceMatchResultPage(Profilo pro)
 {
     InitializeComponent();
     if (pro != null)
     {
         profilo         = pro;
         labelUser.Text  = profilo.utente.name.ToUpper() + " " + profilo.utente.surname.ToUpper();
         result.Source   = ImageSource.FromStream(() => new MemoryStream(profilo.immagine));
         profileBtn.Text = "Vedi profilo";
     }
     else
     {
         result.Source        = "notfound.png";
         requestBtn.IsEnabled = false;
         labelUser.Text       = "Non è stato trovato nessun utente somigliante";
         profileBtn.Text      = "Torna alla home";
     }
 }
Ejemplo n.º 7
0
 public FriendProfilePage(Profilo pro, string op)
 {
     InitializeComponent();
     operation = op;
     if (pro != null)
     {
         profilo = pro;
     }
     labelUser.Text = profilo.utente.name.ToUpper() + " " + profilo.utente.surname.ToUpper();
     if (profilo.utente.sex == "M")
     {
         labelGender.Text = "Maschio";
     }
     else
     {
         labelGender.Text = "Femmina";
     }
     labelDate.Text    = profilo.utente.birth_date.ToString();
     imgProfile.Source = ImageSource.FromStream(() => new MemoryStream(pro.immagine));
 }
        public RegistrationResponse DoRegistration(RegisterViewModel obj)
        {
            if (dao.Connected)
            {
                Utente ut = new Utente
                {
                    Password  = obj.Password,
                    Email     = obj.Email,
                    FirstName = obj.FirstName,
                    LastName  = obj.LastName
                };

                bool ret = DAO.Registration.InsertUtente(dao, ut);

                ut.ID = DAO.Users.GetID(dao, ut.Email, ut.Password);

                if (ret)
                {
                    //Creates a new profile connected to user
                    Profilo profilo = new Profilo {
                        IDUtente = ut.ID
                    };

                    DAO.Registration.InsertProfilo(dao, profilo);
                }

                RegistrationResponse response = new RegistrationResponse
                {
                    Inserted = ret,
                    Utente   = ut
                };

                return(response);
            }
            return(new RegistrationResponse {
                Inserted = false
            });
        }
Ejemplo n.º 9
0
 public ProfilePage(Profilo pro, string op)
 {
     InitializeComponent();
     operation = op;
     if (pro != null)
     {
         altroProfilo = pro;
     }
     modifyBtn.IsVisible  = false;
     backToHomeBtn.Margin = new Thickness(30, 0, 0, 0);
     backToHomeBtn.Text   = "Indietro";
     labelUser.Text       = pro.utente.name.ToUpper() + " " + pro.utente.surname.ToUpper();
     if (mioProfilo.utente.sex == "M")
     {
         labelGender.Text = "Maschio";
     }
     else
     {
         labelGender.Text = "Femmina";
     }
     labelDate.Text    = pro.utente.birth_date.ToString();
     imgProfile.Source = ImageSource.FromStream(() => new MemoryStream(pro.immagine));
 }
Ejemplo n.º 10
0
        public RequestsPage(int i, int id)
        {
            InitializeComponent();
            idUtente = id;
            position = i;
            Profilo profile = richieste[i];

            profilo        = profile;
            labelUser.Text = profilo.utente.name + " " + profilo.utente.surname;
            imgHome.Source = ImageSource.FromStream(() => new MemoryStream(profilo.immagine));
            if (i == 1)
            {
                left.IsVisible = false;
                accept.Margin  = new Thickness(90, 30, 0, 0);
            }
            if (i == richieste.Count)
            {
                right.IsVisible = false;
            }
            var tapImage1 = new TapGestureRecognizer();

            tapImage1.Tapped += OnLeftClicked;
            left.GestureRecognizers.Add(tapImage1);
            var tapImage2 = new TapGestureRecognizer();

            tapImage2.Tapped += OnRightClicked;
            right.GestureRecognizers.Add(tapImage2);
            var tapImage3 = new TapGestureRecognizer();

            tapImage3.Tapped += OnAcceptClicked;
            accept.GestureRecognizers.Add(tapImage3);
            var tapImage4 = new TapGestureRecognizer();

            tapImage4.Tapped += OnDeclineClicked;
            decline.GestureRecognizers.Add(tapImage4);
        }
Ejemplo n.º 11
0
        public HomePage(Profilo pro, string emo, Dictionary <int, Profilo> req, List <Utente> friends, List <Post> posts)
        {
            InitializeComponent();
            var tapImage = new TapGestureRecognizer();

            tapImage.Tapped += OnActionsClicked;
            imgHome.GestureRecognizers.Add(tapImage);
            profilo = pro;
            ModifyPage.SetProfile(profilo);
            ProfilePage.SetMineProfile(profilo);
            userBtn.Text = profilo.utente.name + " " + profilo.utente.surname;
            if (emo != null)
            {
                emozione      = emo;
                labelEmo.Text = "Vedo che al momento provi " + emozione;
            }
            if (friends != null)
            {
                amici = friends;
                ListOfFriendsPage.SetFriends(amici);
                ProfilePage.SetFriends(amici);
            }
            if (posts != null)
            {
                listaPost = posts;
                BoardPage.SetPosts(listaPost);
            }

            ListOfFriendsPage.SetFriends(amici);
            if (req != null)
            {
                richieste = req;
                RequestsPage.SetRequests(richieste);
                this.CheckRequests();
            }
        }
Ejemplo n.º 12
0
        internal string InsertProfilo(Profilo myProfilo, List<TipoDealer> myTipoDealerList, List<AutorizzazioneCampi> myAutorizzazioneCampiList)
        {
            sqlop = new SqlOperations();
            sqlop.databaseConnection = ConfigurationManager.ConnectionStrings["cs"].ToString();

            DbParameter[] dbp = new DbParameter[11];

            dbp[0] = new SqlParameter();
            dbp[0].ParameterName = "NomeProfilo";
            dbp[0].DbType = DbType.String;
            dbp[0].Direction = ParameterDirection.Input;
            dbp[0].Value = myProfilo.NomeProfilo;

            dbp[1] = new SqlParameter();
            dbp[1].ParameterName = "ArchivioDatabase";
            dbp[1].DbType = DbType.Boolean;
            dbp[1].Direction = ParameterDirection.Input;
            dbp[1].Value = myProfilo.ArchivioDatabase;

            dbp[2] = new SqlParameter();
            dbp[2].ParameterName = "ArchivioCruscotto";
            dbp[2].DbType = DbType.Boolean;
            dbp[2].Direction = ParameterDirection.Input;
            dbp[2].Value = myProfilo.ArchivioCruscotto;

            dbp[3] = new SqlParameter();
            dbp[3].ParameterName = "ReportAnomalie";
            dbp[3].DbType = DbType.Boolean;
            dbp[3].Direction = ParameterDirection.Input;
            dbp[3].Value = myProfilo.ReportAnomalie;

            dbp[4] = new SqlParameter();
            dbp[4].ParameterName = "ReportScarti";
            dbp[4].DbType = DbType.Boolean;
            dbp[4].Direction = ParameterDirection.Input;
            dbp[4].Value = myProfilo.ReportScarti;

            dbp[5] = new SqlParameter();
            dbp[5].ParameterName = "Portafoglio";
            dbp[5].DbType = DbType.Boolean;
            dbp[5].Direction = ParameterDirection.Input;
            dbp[5].Value = myProfilo.Portafoglio;

            dbp[6] = new SqlParameter();
            dbp[6].ParameterName = "Amministrazione";
            dbp[6].DbType = DbType.Boolean;
            dbp[6].Direction = ParameterDirection.Input;
            dbp[6].Value = myProfilo.Amministrazione;

            dbp[7] = new SqlParameter();
            dbp[7].ParameterName = "RagioniSocialiCorrelate";
            dbp[7].DbType = DbType.Int32;
            dbp[7].Direction = ParameterDirection.Input;
            dbp[7].Value = myProfilo.RagioniSocialiCorrelate;

            dbp[8] = new SqlParameter();
            dbp[8].ParameterName = "Eccezioni";
            dbp[8].DbType = DbType.Boolean;
            dbp[8].Direction = ParameterDirection.Input;
            dbp[8].Value = myProfilo.Eccezioni;

            XElement tipoDealerXml = new XElement("Dealer",
                            from TipoDealer in myTipoDealerList
                            select new XElement("TipoDealer",
                                    new XElement("IDTipoDealer", TipoDealer.IDTipoDealer)
                                                )
                                    );

            dbp[9] = new SqlParameter();
            dbp[9].ParameterName = "TipoDealerXml";
            dbp[9].DbType = DbType.String;
            dbp[9].Direction = ParameterDirection.Input;
            dbp[9].Value = tipoDealerXml.ToString();

            XElement autorizzazioneCampiXml = new XElement("Autorizzazioni",
                                    from AutorizzazioneCampi in myAutorizzazioneCampiList
                                    select new XElement("AutorizzazioneCampi",
                                            new XElement("IDAutorizzazioneCampi", AutorizzazioneCampi.IDAutorizzazioneCampi),
                                            new XElement("Autorizzazione", AutorizzazioneCampi.Autorizzazione),
                                            new XElement("IDCampoDati", AutorizzazioneCampi.IDCampoDati)
                                                        )
                                                );

            dbp[10] = new SqlParameter();
            dbp[10].ParameterName = "AutorizzazioneCampiXml";
            dbp[10].DbType = DbType.String;
            dbp[10].Direction = ParameterDirection.Input;
            dbp[10].Value = autorizzazioneCampiXml.ToString();

            SqlCommandObject sco = new SqlCommandObject();
            sco.SPName = "Utenti.SP_Profilo_Insert";
            sco.SPParams = dbp;

            DataTable dt;
            string proc = sqlop.ExecuteProcedure(sco, out dt);

            if (proc != string.Empty)
                return proc;

            return "";
        }
Ejemplo n.º 13
0
 public static void InsertProfilo(BaseDAO dao, Profilo profilo)
 {
     dao.DB.Insert(profilo);
 }
Ejemplo n.º 14
0
        async void OnFacebookClicked(object sender, EventArgs args)
        {
            if (App.Authenticator != null)
            {
                var authenticated = await App.Authenticator.Authenticate("Facebook");

                if (authenticated != null)
                {
                    MobileServiceClient client = new MobileServiceClient(Constants.ApplicationURL);
                    Setting.saveCredential(authenticated.user.UserId, authenticated.user.MobileServiceAuthenticationToken);
                    Dictionary <string, string> argoments = new Dictionary <string, string>()
                    {
                        { "provider", "Facebook" },
                        { "a", "a" },
                        { "b", "a" },
                        { "c", "a" }
                    };

                    MobileServiceUser user = new MobileServiceUser(Setting.username);
                    user.MobileServiceAuthenticationToken = Setting.password;
                    client.CurrentUser = user;
                    HttpResponseMessage response = null;
                    try
                    {
                        response = await client.InvokeApiAsync("Login/LoginWithFacebook", null, HttpMethod.Post, null, argoments);

                        if (response.IsSuccessStatusCode)
                        {
                            string json = await response.Content.ReadAsStringAsync();

                            Profilo profilo = JsonConvert.DeserializeObject <Profilo>(json);
                            argoments = new Dictionary <string, string>()
                            {
                                { "id", profilo.utente.ID.ToString() }
                            };
                            response = await client.InvokeApiAsync("Friends/CheckRequest", null, HttpMethod.Post, null, argoments);

                            if (response.IsSuccessStatusCode)
                            {
                                json = await response.Content.ReadAsStringAsync();

                                Dictionary <int, Profilo> requests = JsonConvert.DeserializeObject <Dictionary <int, Profilo> >(json);
                                response = await client.InvokeApiAsync("Friends/ListOfFriends", null, HttpMethod.Post, null, argoments);

                                if (response.IsSuccessStatusCode)
                                {
                                    json = await response.Content.ReadAsStringAsync();

                                    List <Utente> amici = JsonConvert.DeserializeObject <List <Utente> >(json);
                                    argoments = new Dictionary <string, string>()
                                    {
                                        { "id", profilo.utente.ID.ToString() }
                                    };
                                    response = await client.InvokeApiAsync("Social/GetUserPost", null, HttpMethod.Post, null, argoments);

                                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                                    {
                                        json = await response.Content.ReadAsStringAsync();

                                        List <Post> posts = JsonConvert.DeserializeObject <List <Post> >(json);
                                        Application.Current.MainPage = new HomePage(profilo, null, requests, amici, posts);
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
        }
Ejemplo n.º 15
0
 public static void SetMineProfile(Profilo pro)
 {
     mioProfilo = pro;
 }
Ejemplo n.º 16
0
        protected void btnSalvaProfilo_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                Profilo myProfilo = new Profilo();
                myProfilo.IDProfilo               = Convert.ToInt32(IDProfiloHF.Value);
                myProfilo.NomeProfilo             = txtNomeProfilo.Text;
                myProfilo.ArchivioCruscotto       = cruscottoCheckBox.Checked;
                myProfilo.ArchivioDatabase        = databaseCheckBox.Checked;
                myProfilo.ReportAnomalie          = anomalieCheckBox.Checked;
                myProfilo.ReportScarti            = scartiCheckBox.Checked;
                myProfilo.Amministrazione         = amministrazioneCheckBox.Checked;
                myProfilo.Portafoglio             = portafoglioCheckBox.Checked;
                myProfilo.RagioniSocialiCorrelate = Convert.ToInt32(relazioniDropDownList.SelectedValue);
                myProfilo.Eccezioni               = eccezioniCheckBox.Checked;

                List <TipoDealer> myTipoDealerList = new List <TipoDealer>();
                foreach (DataRow dr in TipoDealerTable.Rows)
                {
                    TipoDealer myTipoDealer = new TipoDealer();
                    myTipoDealer.IDTipoDealer = Convert.ToInt32(dr["IDTipoDealer"]);
                    myTipoDealerList.Add(myTipoDealer);
                }

                List <AutorizzazioneCampi> myAutorizzazioneCampiList = new List <AutorizzazioneCampi>();
                foreach (GridViewRow myGridViewRow in autorizzazioneCampiGridView.Rows)
                {
                    if (myGridViewRow.RowType == DataControlRowType.DataRow)
                    {
                        AutorizzazioneCampi myAutorizzazioneCampi = new AutorizzazioneCampi();
                        Label        myIDAutorizzazioneCampiLabel = (Label)myGridViewRow.FindControl("IDAutorizzazioneCampiLabel");
                        DropDownList myAutorizzazioneLabel        = (DropDownList)myGridViewRow.FindControl("autorizzazioneDropDownList");
                        Label        myIDCampoDatiLabel           = (Label)myGridViewRow.FindControl("IDCampoDatiLabel");

                        myAutorizzazioneCampi.IDAutorizzazioneCampi = Convert.ToInt32(myIDAutorizzazioneCampiLabel.Text);
                        myAutorizzazioneCampi.Autorizzazione        = Convert.ToInt32(myAutorizzazioneLabel.SelectedValue);
                        myAutorizzazioneCampi.IDCampoDati           = Convert.ToInt32(myIDCampoDatiLabel.Text);

                        myAutorizzazioneCampiList.Add(myAutorizzazioneCampi);
                    }
                }


                if (myProfilo.IDProfilo == 0)
                {
                    string error = proxyMtd.InsertProfilo(myProfilo, myTipoDealerList, myAutorizzazioneCampiList);

                    if (error != string.Empty)
                    {
                        throw new Exception(error);
                    }
                }
                else
                {
                    string error = proxyMtd.UpdateProfilo(myProfilo, myTipoDealerList, myAutorizzazioneCampiList);

                    if (error != string.Empty)
                    {
                        throw new Exception(error);
                    }
                }

                Response.Redirect("~/Profili.aspx");
            }
            catch (Exception ex)
            {
                PopupMessaggio.ShowMsgBox(ex.Message, true);
            }
        }
Ejemplo n.º 17
0
        internal string InsertProfilo(Profilo myProfilo, List <TipoDealer> myTipoDealerList, List <AutorizzazioneCampi> myAutorizzazioneCampiList)
        {
            sqlop = new SqlOperations();
            sqlop.databaseConnection = ConfigurationManager.ConnectionStrings["cs"].ToString();

            DbParameter[] dbp = new DbParameter[11];

            dbp[0] = new SqlParameter();
            dbp[0].ParameterName = "NomeProfilo";
            dbp[0].DbType        = DbType.String;
            dbp[0].Direction     = ParameterDirection.Input;
            dbp[0].Value         = myProfilo.NomeProfilo;

            dbp[1] = new SqlParameter();
            dbp[1].ParameterName = "ArchivioDatabase";
            dbp[1].DbType        = DbType.Boolean;
            dbp[1].Direction     = ParameterDirection.Input;
            dbp[1].Value         = myProfilo.ArchivioDatabase;

            dbp[2] = new SqlParameter();
            dbp[2].ParameterName = "ArchivioCruscotto";
            dbp[2].DbType        = DbType.Boolean;
            dbp[2].Direction     = ParameterDirection.Input;
            dbp[2].Value         = myProfilo.ArchivioCruscotto;

            dbp[3] = new SqlParameter();
            dbp[3].ParameterName = "ReportAnomalie";
            dbp[3].DbType        = DbType.Boolean;
            dbp[3].Direction     = ParameterDirection.Input;
            dbp[3].Value         = myProfilo.ReportAnomalie;

            dbp[4] = new SqlParameter();
            dbp[4].ParameterName = "ReportScarti";
            dbp[4].DbType        = DbType.Boolean;
            dbp[4].Direction     = ParameterDirection.Input;
            dbp[4].Value         = myProfilo.ReportScarti;

            dbp[5] = new SqlParameter();
            dbp[5].ParameterName = "Portafoglio";
            dbp[5].DbType        = DbType.Boolean;
            dbp[5].Direction     = ParameterDirection.Input;
            dbp[5].Value         = myProfilo.Portafoglio;

            dbp[6] = new SqlParameter();
            dbp[6].ParameterName = "Amministrazione";
            dbp[6].DbType        = DbType.Boolean;
            dbp[6].Direction     = ParameterDirection.Input;
            dbp[6].Value         = myProfilo.Amministrazione;

            dbp[7] = new SqlParameter();
            dbp[7].ParameterName = "RagioniSocialiCorrelate";
            dbp[7].DbType        = DbType.Int32;
            dbp[7].Direction     = ParameterDirection.Input;
            dbp[7].Value         = myProfilo.RagioniSocialiCorrelate;

            dbp[8] = new SqlParameter();
            dbp[8].ParameterName = "Eccezioni";
            dbp[8].DbType        = DbType.Boolean;
            dbp[8].Direction     = ParameterDirection.Input;
            dbp[8].Value         = myProfilo.Eccezioni;

            XElement tipoDealerXml = new XElement("Dealer",
                                                  from TipoDealer in myTipoDealerList
                                                  select new XElement("TipoDealer",
                                                                      new XElement("IDTipoDealer", TipoDealer.IDTipoDealer)
                                                                      )
                                                  );

            dbp[9] = new SqlParameter();
            dbp[9].ParameterName = "TipoDealerXml";
            dbp[9].DbType        = DbType.String;
            dbp[9].Direction     = ParameterDirection.Input;
            dbp[9].Value         = tipoDealerXml.ToString();

            XElement autorizzazioneCampiXml = new XElement("Autorizzazioni",
                                                           from AutorizzazioneCampi in myAutorizzazioneCampiList
                                                           select new XElement("AutorizzazioneCampi",
                                                                               new XElement("IDAutorizzazioneCampi", AutorizzazioneCampi.IDAutorizzazioneCampi),
                                                                               new XElement("Autorizzazione", AutorizzazioneCampi.Autorizzazione),
                                                                               new XElement("IDCampoDati", AutorizzazioneCampi.IDCampoDati)
                                                                               )
                                                           );

            dbp[10] = new SqlParameter();
            dbp[10].ParameterName = "AutorizzazioneCampiXml";
            dbp[10].DbType        = DbType.String;
            dbp[10].Direction     = ParameterDirection.Input;
            dbp[10].Value         = autorizzazioneCampiXml.ToString();

            SqlCommandObject sco = new SqlCommandObject();

            sco.SPName   = "Utenti.SP_Profilo_Insert";
            sco.SPParams = dbp;

            DataTable dt;
            string    proc = sqlop.ExecuteProcedure(sco, out dt);

            if (proc != string.Empty)
            {
                return(proc);
            }

            return("");
        }
Ejemplo n.º 18
0
 public static void SetProfile(Profilo pro)
 {
     profilo = pro;
 }
Ejemplo n.º 19
0
        async void OnConfirmPinClicked(object sender, EventArgs args)
        {
            pinBtn.IsEnabled   = false;
            entryPin.IsEnabled = false;
            spinner.IsRunning  = true;
            spinner.IsVisible  = true;
            MobileServiceClient client            = new MobileServiceClient(Constants.ApplicationURL);
            string      pin                       = entryPin.Text;
            HttpContent content                   = new ByteArrayContent(verifyImg);
            Dictionary <string, string> argoments = new Dictionary <string, string>()
            {
                { "mail", mail },
                { "pin", pin }
            };
            HttpResponseMessage response = await client.InvokeApiAsync("Login/LoginUser", content, HttpMethod.Post, null, argoments);

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                string json = await response.Content.ReadAsStringAsync();

                Profilo profilo = JsonConvert.DeserializeObject <Profilo>(json);
                Setting.saveUserForLogin(profilo.utente.name + " " + profilo.utente.surname, profilo.utente.email);
                content   = new ByteArrayContent(profilo.immagine);
                argoments = new Dictionary <string, string>()
                {
                    { "a", mail }
                };
                response = await client.InvokeApiAsync("Emotize/EmotionRecognize", content, HttpMethod.Post, null, argoments);

                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    json = await response.Content.ReadAsStringAsync();

                    Dictionary <string, decimal> emotions = JsonConvert.DeserializeObject <Dictionary <string, decimal> >(json);
                    decimal max     = -1;
                    string  emotion = null;
                    foreach (var emo in emotions)
                    {
                        if (emo.Value > max)
                        {
                            max     = emo.Value;
                            emotion = emo.Key;
                        }
                    }
                    argoments = new Dictionary <string, string>()
                    {
                        { "id", profilo.utente.ID.ToString() }
                    };
                    response = await client.InvokeApiAsync("Friends/CheckRequest", null, HttpMethod.Post, null, argoments);

                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                    {
                        json = await response.Content.ReadAsStringAsync();

                        Dictionary <int, Profilo> requests = JsonConvert.DeserializeObject <Dictionary <int, Profilo> >(json);
                        argoments = new Dictionary <string, string>()
                        {
                            { "id", profilo.utente.ID.ToString() },
                            { "a", "a" },
                            { "b", "b" },
                            { "c", "c" }
                        };
                        response = await client.InvokeApiAsync("Friends/ListOfFriends", null, HttpMethod.Post, null, argoments);

                        if (response.StatusCode == System.Net.HttpStatusCode.OK)
                        {
                            json = await response.Content.ReadAsStringAsync();

                            List <Utente> amici = JsonConvert.DeserializeObject <List <Utente> >(json);
                            argoments = new Dictionary <string, string>()
                            {
                                { "id", profilo.utente.ID.ToString() }
                            };
                            response = await client.InvokeApiAsync("Social/GetUserPost", null, HttpMethod.Post, null, argoments);

                            if (response.StatusCode == System.Net.HttpStatusCode.OK)
                            {
                                json = await response.Content.ReadAsStringAsync();

                                List <Post> posts = JsonConvert.DeserializeObject <List <Post> >(json);
                                spinner.IsRunning            = false;
                                spinner.IsVisible            = false;
                                pinBtn.IsEnabled             = true;
                                Application.Current.MainPage = new HomePage(profilo, emotion, requests, amici, posts);
                            }
                            else
                            {
                                await DisplayAlert("Attenzione", "Comunicazione col server fallita", "OK");

                                App.Current.MainPage = new IntroPage();
                            }
                        }
                        else
                        {
                            await DisplayAlert("Attenzione", "Comunicazione col server fallita", "OK");

                            App.Current.MainPage = new IntroPage();
                        }
                    }
                    else
                    {
                        await DisplayAlert("Attenzione", "Comunicazione col server fallita", "OK");

                        App.Current.MainPage = new IntroPage();
                    }
                }
                else
                {
                    await DisplayAlert("Attenzione", "Comunicazione col server fallita", "OK");

                    App.Current.MainPage = new IntroPage();
                }
            }
            else
            {
                spinner.IsRunning = false;
                pinBtn.IsEnabled  = true;
                if (response.StatusCode == System.Net.HttpStatusCode.ResetContent)
                {
                    await DisplayAlert("Attenzione", "La persona della foto utilizzata per effettuare il login " +
                                       "non corrisponde a quella del profilo. Accesso negato.", "OK");
                }
                if (response.StatusCode == System.Net.HttpStatusCode.NoContent)
                {
                    await DisplayAlert("Attenzione", "Non è stato trovato l'utente con cui si vuole effettuare " +
                                       "l'accesso", "OK");
                }
                if (response.StatusCode == System.Net.HttpStatusCode.Created)
                {
                    await DisplayAlert("Attenzione", "Comunicazione col server fallita", "OK");
                }
                App.Current.MainPage = new IntroPage();
            }
        }