public bool FindRut(int Rut) { AxonAccessMVC.Models.Mae_Usuario ru = db.Mae_Usuario.FirstOrDefault(u => u.rut == Rut); try { if (ru == null) { return(true); } else if (ru.rut == Rut) { return(false); } else { return(true); } } catch (Exception) { return(false); } }
public List <Usuario> ReadAll() { string userMail = HttpContext.Current.User.Identity.Name; AxonAccessMVC.Models.Mae_Usuario resss = db.Mae_Usuario.FirstOrDefault (u => u.mail == userMail); if (resss.id_role == 4) { return((from us in db.Mae_Usuario join ro in db.Ref_Role on us.id_role equals ro.id_role join suc in db.Mae_Sucursal on us.id_sucursal equals suc.id_sucursal join acc in db.Ref_accessTipo on us.id_access_tipo equals acc.id_access_tipo join emp in db.Mae_Empresa on us.id_empresa equals emp.id_empresa where us.id_role == 4 || us.id_role == 5 select new Models.Clases.Usuario { Id = (int)us.id_usuario, Id_Role = (int)us.id_role, Desc_Role = ro.desc_role, Id_Estado = (int)us.id_estado, Id_Comuna = (int)us.id_comuna, Id_Empresa = (int)us.id_empresa, Rut = (int)us.rut, Dv = us.dv, Nombre = us.nombre, App_Pater = us.app_pater, App_Mater = us.app_mater, Direccion = us.direccion, Telefono = (int)us.telefono, Mail = us.mail, Pass = us.pass, Latitud = us.latitud, Longitud = us.longitud, Cargo = us.cargo, Cod_Pais = us.cod_pais, Id_Sucursal = (int)us.id_sucursal, Desc_Sucursal = suc.descripcion, Desc_Access = acc.desc_Access_tipo, Desc_Empresa = emp.desc_empresa }).OrderBy(x => x.Id_Role).ToList()); } else if (resss.id_role == 5) { return((from us in db.Mae_Usuario join ro in db.Ref_Role on us.id_role equals ro.id_role join suc in db.Mae_Sucursal on us.id_sucursal equals suc.id_sucursal join acc in db.Ref_accessTipo on us.id_access_tipo equals acc.id_access_tipo where us.id_role == 5 && us.mail == userMail select new Models.Clases.Usuario { Id = (int)us.id_usuario, Id_Role = (int)us.id_role, Desc_Role = ro.desc_role, Id_Estado = (int)us.id_estado, Id_Comuna = (int)us.id_comuna, Id_Empresa = (int)us.id_empresa, Rut = (int)us.rut, Dv = us.dv, Nombre = us.nombre, App_Pater = us.app_pater, App_Mater = us.app_mater, Direccion = us.direccion, Telefono = (int)us.telefono, Mail = us.mail, Pass = us.pass, Latitud = us.latitud, Longitud = us.longitud, Cargo = us.cargo, Cod_Pais = us.cod_pais, Id_Sucursal = (int)us.id_sucursal, Desc_Sucursal = suc.descripcion, Desc_Access = acc.desc_Access_tipo }).OrderBy(x => x.Id_Role).ToList()); } else { return((from us in db.Mae_Usuario join ro in db.Ref_Role on us.id_role equals ro.id_role join suc in db.Mae_Sucursal on us.id_sucursal equals suc.id_sucursal join acc in db.Ref_accessTipo on us.id_access_tipo equals acc.id_access_tipo select new Models.Clases.Usuario { Id = (int)us.id_usuario, Id_Role = (int)us.id_role, Desc_Role = ro.desc_role, Id_Estado = (int)us.id_estado, Id_Comuna = (int)us.id_comuna, Id_Empresa = (int)us.id_empresa, Rut = (int)us.rut, Dv = us.dv, Nombre = us.nombre, App_Pater = us.app_pater, App_Mater = us.app_mater, Direccion = us.direccion, Telefono = (int)us.telefono, Mail = us.mail, Pass = us.pass, Latitud = us.latitud, Longitud = us.longitud, Cargo = us.cargo, Cod_Pais = us.cod_pais, Id_Sucursal = (int)us.id_sucursal, Desc_Sucursal = suc.descripcion, Desc_Access = acc.desc_Access_tipo }).OrderBy(x => x.Id_Role).ToList()); } }