Example #1
0
 /// <summary>
 /// Create a new Endereco object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="rua">Initial value of the Rua property.</param>
 /// <param name="numero">Initial value of the Numero property.</param>
 /// <param name="bairro">Initial value of the Bairro property.</param>
 /// <param name="cidade">Initial value of the Cidade property.</param>
 /// <param name="estado">Initial value of the Estado property.</param>
 /// <param name="usuarioEnderecos_Endereco_Id">Initial value of the UsuarioEnderecos_Endereco_Id property.</param>
 public static Endereco CreateEndereco(global::System.Int32 id, global::System.String rua, global::System.Int32 numero, global::System.String bairro, global::System.String cidade, global::System.String estado, global::System.Int32 usuarioEnderecos_Endereco_Id)
 {
     Endereco endereco = new Endereco();
     endereco.Id = id;
     endereco.Rua = rua;
     endereco.Numero = numero;
     endereco.Bairro = bairro;
     endereco.Cidade = cidade;
     endereco.Estado = estado;
     endereco.UsuarioEnderecos_Endereco_Id = usuarioEnderecos_Endereco_Id;
     return endereco;
 }
Example #2
0
        protected void btnCadastro_Click(object sender, DirectEventArgs e)
        {
            /*
            if (IsValidCustom(e.ExtraParams["challengeValue"], e.ExtraParams["responseValue"])) // Check if Captcha is verified or not.
            {
                // Captcha provided by the user is valid.
                FormsAuthentication.SetAuthCookie(this.txtUsername.Text, false);
            }
            //else
            {
                // Captcha provided by the user is invalid.
                X.MessageBox.Alert("Erro", "Código invalido.").Show();
            }
             */
            if (string.IsNullOrWhiteSpace(this.Senha.Text))
            {
                X.MessageBox.Alert("Erro", "Senha invalida.").Show();
                return;
            }
            Usuario usuario = new Usuario
            {
                Email = this.EmailCadastro.Text,
                Senha = FormsAuthentication.HashPasswordForStoringInConfigFile(this.Senha.Text, "md5")
            };
            Telefone Fixo    = ObterTelefoneFixo();
            Telefone Celular = ObterTelefoneCelular();
            if (Fixo == null && Celular == null)
            {
                X.MessageBox.Alert("Erro", "Pelo menos um telefone é necessário. Favor preencher ou telefone fixo ou telefone celular.").Show();
                return;
            }

            int numCad;
            if (int.TryParse(this.NumeroCadastro.Text, out numCad))
            {
                var Endereco = new Endereco
                {
                    Rua = this.RuaCadastro.Text,
                    Numero = numCad,
                    Complemento = this.ComplementoCadastro.Text,
                    Bairro = this.BairroCadastro.Text,
                    Cidade = "Belo Horizonte",
                    Estado = "Minas Gerais"
                };
                if (Endereco.IsValid)
                {
                    using (var repositorio = new Repositorio())
                    {
                        repositorio.Add(Endereco);

                        Endereco.Usuario = usuario;

                        repositorio.Add(usuario);

                        if (Fixo != null)
                        {
                            Fixo.Usuario = usuario;
                            repositorio.Add(Fixo);
                        }

                        if (Celular != null)
                        {
                            Celular.Usuario = usuario;
                            repositorio.Add(Celular);
                        }

                        repositorio.Save();
                    }
                }
                else
                {
                    X.MessageBox.Alert("Erro", "Endereço invalido.").Show();
                    return;
                }
            }
        }
Example #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Endereco EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToEndereco(Endereco endereco)
 {
     base.AddObject("Endereco", endereco);
 }