// /// <summary> /// Return one user translated to DTO, /// including the server DTO if found. /// </summary> /// <param name="userName"></param> /// <param name="serverShortName"></param> /// <returns></returns> public UserServerData GetUserServerByUserName(string userName, string serverShortName) { UserServerData _user = null; if (serverShortName == null) { serverShortName = ""; } var _usersEntity = _niEntities.Users. FirstOrDefault(_r => _r.UserName == userName); if (_usersEntity != null) { _user = _usersEntity.ToUserServerData(); if (serverShortName != "") { serverShortName = serverShortName.ToLower(); ApplicationServer _srv = _usersEntity.Servers.FirstOrDefault(_s => _s.ServerShortName.ToLower() == serverShortName); if (_srv != null) { _user.Server = _srv.ToServerData( ); _user.ServerShortName = serverShortName; } } } return(_user); }