using System;
using System.Web.Security;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using QuintoCaminoV2.Data_objects;

namespace QuintoCaminoV2.Account
{
    public partial class Register : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Unnamed11_Click1(object sender, EventArgs e)
        {
            DataLayer oDataLayer = new DataLayer();
            Data_objects.Usuarios oUser = new Data_objects.Usuarios();
            oUser.vchEmail = Email.Text;

            if (oDataLayer.get_UsuarioByEmail(oUser).Count > 0)
            {
                return;
            }

            List<Usuarios> lstUsu = new List<Usuarios>();

            oUser.vchContrasena = Password.Text;
            oUser.vchMovil = Movil.Text;
            oUser.vchUsuario = UserName.Text;
            oUser.vchTelefono = Telefono.Text;
            lstUsu.Add(oUser);

            Errores oErrores = new Errores();
            oErrores = oDataLayer.insertUsuario(lstUsu);

            if (!(oErrores.bitError))
            {
                FormsAuthentication.SetAuthCookie(this.UserName.Text, true);
                Response.Redirect("~/Users/User.aspx");
            }
        }
    }
}