示例#1
0
    public static List <Usuario> getAdmin()
    {
        UsuariosDSTableAdapters.UsuarioTableAdapter adapter = new UsuariosDSTableAdapters.UsuarioTableAdapter();
        UsuariosDS.UsuarioDataTable table = adapter.GetAdmin();

        List <Usuario> resultado = new List <Usuario>();

        foreach (var row in table)
        {
            Usuario obj = new Usuario();

            obj.UsuarioId    = row.usuarioId;
            obj.Nombre       = row.nombre;
            obj.Apellido     = row.apellido;
            obj.Email        = row.email;
            obj.Contraseña   = row.contraseña;
            obj.Estado       = row.estado;
            obj.EstadoActual = row.estadoActual;
            obj.TipoUsuario  = row.tipoUsuario;

            resultado.Add(obj);
        }

        return(resultado);
    }
示例#2
0
    public static void eliminarUsuario(int usuarioId)
    {
        if (usuarioId <= 0)
        {
            throw new ArgumentException("El id del usuario no puede ser menor a 1");
        }
        string estado = "inactivo";

        UsuariosDSTableAdapters.UsuarioTableAdapter adapter = new UsuariosDSTableAdapters.UsuarioTableAdapter();
        adapter.Delete(usuarioId, estado);
    }
示例#3
0
    public static int insertarUsuario(Usuario obj)
    {
        if (obj == null)
        {
            throw new ArgumentException("El objeto a insertar no puede tener un valor nulo");
        }

        if (string.IsNullOrEmpty(obj.Nombre))
        {
            throw new ArgumentException("el Nombre no puede ser nulo ni vacio");
        }

        if (string.IsNullOrEmpty(obj.Apellido))
        {
            throw new ArgumentException("el Apellido no puede ser nulo ni vacio");
        }

        if (string.IsNullOrEmpty(obj.Email))
        {
            throw new ArgumentException("el Email no puede ser nulo ni vacio");
        }

        if (string.IsNullOrEmpty(obj.Contraseña))
        {
            throw new ArgumentException("el Contraseña no puede ser nulo ni vacio");
        }

        if (string.IsNullOrEmpty(obj.TipoUsuario))
        {
            throw new ArgumentException("el Tipo de usuario no puede ser nulo ni vacio");
        }

        if (string.IsNullOrEmpty(obj.Estado))
        {
            throw new ArgumentException("el Estado no puede ser nulo ni vacio");
        }

        int?usuarioId = 0;

        UsuariosDSTableAdapters.UsuarioTableAdapter adapter = new UsuariosDSTableAdapters.UsuarioTableAdapter();
        adapter.Insert(obj.Nombre, obj.Apellido, obj.Email, obj.Contraseña, obj.TipoUsuario, obj.Estado, obj.EstadoActual, ref usuarioId);

        if (usuarioId == null || usuarioId.Value <= 0)
        {
            throw new Exception("La llave primaria no se genero correctamente");
        }

        return(usuarioId.Value);
    }
示例#4
0
    public static Usuario getUsuariosActivos()
    {
        UsuariosDSTableAdapters.UsuarioTableAdapter adapter = new UsuariosDSTableAdapters.UsuarioTableAdapter();
        UsuariosDS.UsuarioDataTable table = adapter.GetUsuarioActivos();

        Usuario obj = new Usuario();

        var row = table[0];

        obj.UsuarioId = row.usuarioId;
        obj.Nombre    = row.nombre;
        obj.Apellido  = row.apellido;

        return(obj);
    }
示例#5
0
    public static void actualizarEstadoUsuario(string actual, int codUsuario)
    {
        if (codUsuario < 0)
        {
            throw new ArgumentException("Debe ser mayor a 0");
        }

        if (string.IsNullOrEmpty(actual))
        {
            throw new ArgumentException("El Nombre no puede estar Vacio");
        }

        UsuariosDSTableAdapters.UsuarioTableAdapter adapter = new UsuariosDSTableAdapters.UsuarioTableAdapter();
        adapter.GetUpdateEstadoUsuario(actual, codUsuario);
    }
示例#6
0
    public static void actualizarUsuario(string nombre, string apellido, int usuarioId)
    {
        if (string.IsNullOrEmpty(nombre))
        {
            throw new ArgumentException("El Nombre no puede estar Vacio");
        }

        if (string.IsNullOrEmpty(apellido))
        {
            throw new ArgumentException("El Apellido no puede estar Vacio");
        }

        if (usuarioId == 0)
        {
            throw new ArgumentException("el codigo de Usuario no puede ser 0");
        }

        UsuariosDSTableAdapters.UsuarioTableAdapter adapter = new UsuariosDSTableAdapters.UsuarioTableAdapter();
        adapter.Update(nombre, apellido, usuarioId);
    }
示例#7
0
    public static Usuario GetAdminByEmail(string userEmail)
    {
        if (string.IsNullOrEmpty(userEmail))
        {
            throw new ArgumentException("El Email no puede ser nulo ni vacio");
        }

        UsuariosDSTableAdapters.UsuarioTableAdapter adapter = new UsuariosDSTableAdapters.UsuarioTableAdapter();
        UsuariosDS.UsuarioDataTable table = adapter.GetAdminByEmail(userEmail);

        if (table.Rows.Count == 0)
        {
            return(null);
        }

        if (table.Rows.Count == 0)
        {
            return(null);
        }

        Usuario obj = GetUsuarioFromRow(table[0]);

        return(obj);
    }
示例#8
0
    public static Usuario getUsuariosById(int usuarioId)
    {
        if (usuarioId <= 0)
        {
            throw new ArgumentException("El id del usuario no puede ser menor a 1");
        }

        UsuariosDSTableAdapters.UsuarioTableAdapter adapter = new UsuariosDSTableAdapters.UsuarioTableAdapter();
        UsuariosDS.UsuarioDataTable table = adapter.GetUsuarioById(usuarioId);

        List <Usuario> resultado = new List <Usuario>();

        var row = table[0];

        Usuario obj = new Usuario();

        obj.UsuarioId = row.usuarioId;
        obj.Nombre    = row.nombre;
        obj.Apellido  = row.apellido;

        resultado.Add(obj);

        return(obj);
    }