Beispiel #1
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;
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// Create a new Usuario object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="email">Initial value of the Email property.</param>
 /// <param name="senha">Initial value of the Senha property.</param>
 public static Usuario CreateUsuario(global::System.Int32 id, global::System.String email, global::System.String senha)
 {
     Usuario usuario = new Usuario();
     usuario.Id = id;
     usuario.Email = email;
     usuario.Senha = senha;
     return usuario;
 }
Beispiel #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Usuario EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUsuario(Usuario usuario)
 {
     base.AddObject("Usuario", usuario);
 }
Beispiel #4
0
 public static void AlterarUsuario(Usuario CurrentUser)
 {
     HttpContext.Current.Session["ControleInterno.User"] = CurrentUser;
 }