Пример #1
0
        private async void Save()
        {
            if (string.IsNullOrEmpty(this.profilePhone.Name))
            {
                await Application.Current.MainPage.DisplayAlert(
                    Languages.Error,
                    Languages.NameValidation,
                    Languages.Accept);

                return;
            }
            if (string.IsNullOrEmpty(this.profilePhone.Number))
            {
                await Application.Current.MainPage.DisplayAlert(
                    Languages.Error,
                    Languages.NumberValidation,
                    Languages.Accept);

                return;
            }
            if (!(this.profilePhone.Number).ToCharArray().All(Char.IsDigit))
            {
                await Application.Current.MainPage.DisplayAlert(
                    Languages.Error,
                    Languages.NumberValidation,
                    Languages.Accept);

                return;
            }
            if (this.profilePhone.Number.Length != 10)
            {
                await Application.Current.MainPage.DisplayAlert(
                    Languages.Error,
                    Languages.PhoneValidation2,
                    Languages.Accept);

                return;
            }
            this.IsRunning = true;
            this.IsEnabled = false;

            var checkConnetion = await this.apiService.CheckConnection();

            if (!checkConnetion.IsSuccess)
            {
                this.IsRunning = false;
                this.IsEnabled = true;
                await Application.Current.MainPage.DisplayAlert(
                    Languages.Error,
                    checkConnetion.Message,
                    Languages.Accept);

                return;
            }

            var apiSecurity = Application.Current.Resources["APISecurity"].ToString();
            var profile     = await this.apiService.PutProfile(
                apiSecurity,
                "/api",
                "/ProfilePhones/PutProfilePhone",
                profilePhone);

            this.IsRunning = false;
            this.IsEnabled = true;

            #region LastCode2
            //string consultaDefault = "select * from dbo.ProfilePhones where dbo.ProfilePhones.ProfilePhoneId = "
            //                            + profilephone.ProfilePhoneId;
            //string cadenaConexion = @"data source=serverappmyinfonfc.database.windows.net;initial catalog=mynfo;user id=adminatxnfc;password=4dmiNFC*Atx2020;Connect Timeout=60";

            //ProfilePhone _profilePhone = new ProfilePhone();

            //using (SqlConnection connection = new SqlConnection(cadenaConexion))
            //{
            //    System.Text.StringBuilder sb = new System.Text.StringBuilder();
            //    sb.Append(consultaDefault);
            //    string sql = sb.ToString();

            //    using (SqlCommand command = new SqlCommand(sql, connection))
            //    {
            //        connection.Open();
            //        using (SqlDataReader reader = command.ExecuteReader())
            //        {
            //            while (reader.Read())
            //            {
            //                _profilePhone.ProfilePhoneId = (int)reader["ProfilePhoneId"];
            //                _profilePhone.Name = (string)reader["Name"];
            //                _profilePhone.UserId = (int)reader["UserId"];
            //                _profilePhone.Number = (string)reader["Number"];
            //            }
            //        }
            //        connection.Close();
            //    }
            //}
            #endregion


            MainViewModel.GetInstance().ProfilesByPhone.updateProfile(profile);

            await App.Navigator.PopAsync();
        }
Пример #2
0
 private void BackHome()
 {
     MainViewModel.GetInstance().Home = new HomeViewModel();
     Application.Current.MainPage = new MasterPage();
 }