Exemplo n.º 1
0
        public static Usuario UsuarioChangeStatus(int id_usuario, bool status)
        {
            Usuario oU = new Usuario();

            try
            {
                oU.Id = id_usuario;
                UsuarioMng oBMng = new UsuarioMng();
                oBMng.O_Usuario = oU;
                oBMng.selById();

                if (status)
                {
                    oBMng.dlt();
                }
                else
                {
                    oBMng.reactive();
                }
            }
            catch
            {
                throw;
            }
            return(oU);
        }
Exemplo n.º 2
0
        public static List <Usuario> UsuarioSelByRolAndBodega(enumRol rol, int id_bodega)
        {
            List <Usuario> lstBodega = new List <Usuario>();
            List <Usuario> lstRol    = new List <Usuario>();

            try
            {
                UsuarioMng oUMng = new UsuarioMng();
                Usuario    o     = new Usuario()
                {
                    Id_bodega = id_bodega
                };
                oUMng.O_Usuario = o;
                oUMng.fillLst();
                lstBodega = oUMng.Lst.FindAll(p => p.Id_bodega == id_bodega);

                string[] strRoles;

                foreach (Usuario itemUsr in lstBodega)
                {
                    strRoles = Roles.GetRolesForUser(itemUsr.Clave);
                    if (Array.Exists(strRoles, p => p.Equals(rol.ToString())))
                    {
                        itemUsr.Contrasenia = string.Empty;
                        lstRol.Add(itemUsr);
                    }
                }
            }
            catch
            {
                throw;
            }
            return(lstRol);
        }
Exemplo n.º 3
0
        //public static bool UsuarioHasRol(Usuario o, enumRol rol)
        //{
        //    bool hasRol = false;
        //    List<string> roles = Roles.GetRolesForUser(o.Clave).ToList();
        //    hasRol = roles.Exists(p => string.Compare(p.ToString(), rol.ToString()) == 0);
        //    return hasRol;
        //}

        public static List <Usuario> usuarioFillAllList()
        {
            List <Usuario> lst = new List <Usuario>();

            try
            {
                UsuarioMng oUMng = new UsuarioMng();
                oUMng.fillAllLst();
                lst = oUMng.Lst;
            }
            catch
            {
                throw;
            }
            return(lst);
        }
Exemplo n.º 4
0
        public static void usuarioUdt(Usuario oU)
        {
            IDbTransaction trans = null;

            try
            {
                trans = GenericDataAccess.BeginTransaction();
                UsuarioMng oUMng = new UsuarioMng();
                oUMng.O_Usuario = oU;
                oUMng.udt(trans);

                Usuario_bodega oUB = new Usuario_bodega()
                {
                    Id_usuario = oU.Id
                };
                Usuario_bodegaMng OUBMng = new Usuario_bodegaMng()
                {
                    O_Usuario_bodega = oUB
                };
                OUBMng.deleteByUsuario(trans);

                foreach (Usuario_bodega itemUB in oU.PLstUsuarioBodega)
                {
                    OUBMng = new Usuario_bodegaMng()
                    {
                        O_Usuario_bodega = new Usuario_bodega()
                        {
                            Id_usuario = itemUB.Id_usuario, Id_bodega = itemUB.Id_bodega
                        }
                    };
                    OUBMng.add(trans);
                }

                GenericDataAccess.CommitTransaction(trans);
            }
            catch
            {
                if (trans != null)
                {
                    GenericDataAccess.RollbackTransaction(trans);
                }
                throw;
            }
        }
Exemplo n.º 5
0
        public static Usuario UsuarioSelById(int id_usuario)
        {
            Usuario o = new Usuario();

            try
            {
                o.Id = id_usuario;
                UsuarioMng oUMng = new UsuarioMng()
                {
                    O_Usuario = o
                };
                oUMng.selById();
            }
            catch
            {
                throw;
            }
            return(o);
        }
Exemplo n.º 6
0
        public static Usuario UsuarioCredencialesValidas(string email, string password)
        {
            Usuario o = new Usuario()
            {
                Email = email
            };

            try
            {
                UsuarioMng oMng = new UsuarioMng()
                {
                    O_Usuario = o
                };
                oMng.selByEmail();
                if (string.Compare(password, o.Contrasenia) != 0)
                {
                    o = new Usuario();
                }
            }
            catch
            {
            }
            return(o);
        }
Exemplo n.º 7
0
        public static Usuario UsuarioSelByClaveContrasenia(string username, string password)
        {
            Usuario o = new Usuario();

            try
            {
                o.Clave       = username;
                o.Contrasenia = password;
                UsuarioMng oUMng = new UsuarioMng()
                {
                    O_Usuario = o
                };
                oUMng.selByClaveContrasenia();
                if (o.Id <= 0)
                {
                    throw new Exception("El nombre de usuario y/o contraseña son incorrectos " + o.Id.ToString());
                }
            }
            catch
            {
                throw;
            }
            return(o);
        }