public IUsrDTO LoadUsrR(String cemexId, int idPais) { try { catUsr usrD = Load(cemexId); IPaisDAO pDAO = new PaisDAO(); catPais paisD = PaisDAO.DTOtoE(pDAO.Load(idPais)); var idRol = from r in ObjCtxSCAdmIns.Instance.SCAdmEntity().catRol join relPUR in ObjCtxSCAdmIns.Instance.SCAdmEntity().relPaUsrRol on r.IdRol equals relPUR.IdRol where relPUR.CemexID == cemexId & relPUR.IdPais == idPais select r.IdRol; var IdSta = from s in ObjCtxSCAdmIns.Instance.SCAdmEntity().catStaRg join relPUR in ObjCtxSCAdmIns.Instance.SCAdmEntity().relPaUsrRol on s.IdStaRg equals relPUR.IdStaRg where relPUR.CemexID == cemexId & relPUR.IdPais == idPais select s.IdStaRg; IRolDAO rDAO = new RolDAO(); catRol rolD = (idRol.ToList().Count > 0 ? RolDAO.DTOtoE(rDAO.Load(idRol.First())) : null); IStaRgDAO sDAO = new StaRgDAO(); catStaRg staD = (IdSta.ToList().Count > 0 ? sDAO.Load(IdSta.First()) : null); return(EtoDTO(usrD, paisD, rolD, staD)); } catch (InstanceNotFoundException) { return(null); } catch (Exception) { throw; } }
public static UsrDTO EtoDTO(catUsr usr, catPais pais, catRol rol, catStaRg sta) { return(usr != null ? new UsrDTO(usr.CemexID, usr.NUsuario, usr.Email, RolDAO.EtoDTO(rol), PaisDAO.EtoDTO(pais), StaRgDAO.EtoDTO(sta)) : null); }