Exemplo n.º 1
0
        protected void btnSubmitRegister_Click(object sender, DirectEventArgs e)
        {
            if (!this.txtRegisterPassword.Value.Equals(this.txtRegisterRepeat.Value))
            {
                X.Msg.Show(new MessageBoxConfig
                {
                    Title = "Invalid Information",
                    Message = "Password doesn't match",
                    Buttons = MessageBox.Button.OK,
                    Icon = MessageBox.Icon.ERROR
                });
            }
            else
            {

                    using (TodoDBEntities context = new TodoDBEntities())
                    {
                        usuario newUsuario = new usuario
                        {
                            email = txtRegisterEmail.Value.ToString(),
                            password = FormsAuthentication.HashPasswordForStoringInConfigFile(txtRegisterPassword.Value.ToString(), "SHA1"),
                        };
                        context.usuarios.AddObject(newUsuario);
                        try
                        {
                            context.SaveChanges();
                        }catch(Exception error){
                            X.Msg.Show(new MessageBoxConfig
                            {
                                Title = "Duplicated Email!",
                                Message = "The Email already exist!",
                                Buttons = MessageBox.Button.OK,
                                Icon = MessageBox.Icon.ERROR
                            });
                            return;
                        }

                    }

                X.Msg.Show(new MessageBoxConfig
                {
                    Title = "Welcome!",
                    Message = "You have been registed successfully",
                    Buttons = MessageBox.Button.OK,
                    Icon = MessageBox.Icon.INFO
                });
                windowRegister.Hidden = true;
            }
        }
 /// <summary>
 /// Create a new usuario object.
 /// </summary>
 /// <param name="email">Initial value of the email property.</param>
 /// <param name="password">Initial value of the password property.</param>
 public static usuario Createusuario(global::System.String email, global::System.String password)
 {
     usuario usuario = new usuario();
     usuario.email = email;
     usuario.password = password;
     return usuario;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the usuarios EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTousuarios(usuario usuario)
 {
     base.AddObject("usuarios", usuario);
 }