Beispiel #1
0
        private static void crearUsuario()
        {
            Paciente newP = new Paciente();
            newP.nombres_paciente = "fernando";
            newP.apellidos_paciente = "Pruebas Calima";
            newP.ident_paciente = "10889";
            newP.tipo_id = 1;
            newP.telefono_paciente = "318788545";
            newP.movil_paciente = "318788545";
            newP.direccion_paciente = "av siempre viva calle falsa 124";
            newP.genero_paciente = 2;

            newP.fecha_nacimiento = new DateTime(1987, 03, 6);
            PacienteDao pd = new PacienteDao();
            pd.registrarPacienteNuevo(newP);
        }
    public static object CrearUsuario(string Nombres, string Apellidos, int TIPO_IDENTIFICACION, string NUMERO_IDENTIFICACION,
        string Direccion, string telefono,
       string userName, string Email, string passwordQuestion, string SecurityAnswer)
    {
        string PERFILP = "PACIENTE";
        string Retorno = "";
        string status = "";
        MembershipUser a = Membership.GetUser(userName);

        string porEmail = string.Empty;
        porEmail = Membership.GetUserNameByEmail(Email);
        if (a == null && string.IsNullOrEmpty(porEmail))
        {
            #region ("Creacion")
            MembershipCreateStatus createStatus;
            MembershipUser newUser =
                       Membership.CreateUser(userName, NUMERO_IDENTIFICACION,
                                             Email, passwordQuestion,
                                             SecurityAnswer, true,
                                             out createStatus);

            switch (createStatus)
            {
                case MembershipCreateStatus.Success:
                    Roles.AddUserToRole(userName, PERFILP);

                    Paciente nuevoPaciente = new Paciente();
                    nuevoPaciente.nombres_paciente = Nombres;
                    nuevoPaciente.apellidos_paciente = Apellidos;
                    nuevoPaciente.ident_paciente = NUMERO_IDENTIFICACION;
                    nuevoPaciente.tipo_id = TIPO_IDENTIFICACION;
                    nuevoPaciente.genero_paciente = 2;

                    nuevoPaciente.direccion_paciente = Direccion;
                    nuevoPaciente.telefono_paciente = telefono;
                    nuevoPaciente.movil_paciente = telefono;
                    nuevoPaciente.mail_paciente = Email;
                    nuevoPaciente.userId = newUser.ProviderUserKey.ToString();
                    nuevoPaciente.fecha_nacimiento = DateTime.Now;

                    PacienteDao pd = new PacienteDao();
                    var nuevo = pd.registrarPacienteNuevo(nuevoPaciente);

                    var enviar = new Correos().EnviarEmailCreacionDeUsuario(Email);

                    status = "OK";
                    Retorno = "La cuenta del usuario, ha sido creada con exito";

                    break;

                case MembershipCreateStatus.DuplicateUserName:
                    status = "Existe";
                    Retorno = "Ya existe un usuario con ese nombre de usuario";
                    //CreateAccountResults.Text = "Ya existe un usuario con ese nombre de usuario";//"There already exists a user with this username.";
                    break;

                case MembershipCreateStatus.DuplicateEmail:
                    status = "Duplicado";
                    Retorno = "Ya existe un usuario con este email.";// "There already exists a user with this email address.";
                    break;

                case MembershipCreateStatus.InvalidEmail:
                    status = "email";
                    Retorno = "La dirección de correo electrónico que nos ha facilitado en inválida.";//"There email address you provided in invalid.";
                    break;

                case MembershipCreateStatus.InvalidPassword:
                    status = "password";
                    Retorno = "La contraseña que ha proporcionado no es válido. Debe ser de siete caracteres y tener al menos un carácter no alfanumérico.";//"The password you provided is invalid. It must be seven characters long and have at least one non-alphanumeric character.";
                    break;

                default:
                    status = "Error";
                    Retorno = "Hubo un error desconocido, la cuenta de usuario no fue creado.";//"There was an unknown error; the user account was NOT created.";
                    break;
            }
            #endregion
        }
        else
        {
            if (a != null)
            {
                status = "Existe";
                Retorno = "El nombre de usuario ya existe.";
            }
            //        CreateAccountResults.Text = "El usuario ya existe";

            if (!string.IsNullOrEmpty(porEmail))
            {
                status = "EmailCambiar";
                Retorno = "Ingrese por favor una dirección de correo electrónico diferente.";
            }
        }
        return new
        {
            status = status,
            mensaje = Retorno
        };
    }
 public int registrarPacienteNuevo(Entity.Paciente pacienteNuevo)
 {
     PacienteDao pd = new PacienteDao();
     return pd.registrarPacienteNuevo(pacienteNuevo);
 }