IObservable <HubRequest> LoadRequestImpl(Guid id, Guid dataMartId) { var dm = _networkSetting.DataMartList.FirstOrDefault(d => d.DataMartId == dataMartId); return(from r in DnsServiceManager.GetRequests(_networkSetting, new[] { id }, dataMartId).SkipWhile(r => r.ID != id).Take(1) let rt = r.Routings.EmptyIfNull().FirstOrDefault(x => x.DataMartID == dataMartId) where rt != null select new HubRequest { Source = r, DataMartId = dataMartId, NetworkId = _networkSetting.NetworkId, NetworkName = _networkSetting.NetworkName, DataMartName = dm == null ? null : dm.DataMartName, DataMartOrgId = dm == null ? null : dm.OrganizationId, DataMartOrgName = dm == null ? null : dm.OrganizationName, ProjectName = r != null && r.Project != null ? r.Project.Name : null, Properties = rt.Properties.EmptyIfNull().GroupBy(p => p.Name).ToDictionary(pp => pp.Key, pp => pp.First().Value), Rights = r.Routings.Where(rn => rn.DataMartID == dataMartId).Select(rn => (HubRequestRights)rn.Rights).FirstOrDefault(), RoutingStatus = rt.Status, SubmittedDataMarts = string.Join(", ", from rtng in r.Routings join dmt in _networkSetting.DataMartList on rtng.DataMartID equals dmt.DataMartId select dmt.DataMartName), Documents = r.Documents.EmptyIfNull().ToArray() }); }