public override SyncFeedEntry GetFeedEntry(string id) { SyncFeedEntry result = new SyncFeedEntry(); result.Payload = PayloadFactory.CreatePayload(_resourceKind); Identity identity; AccountDocument accountDocument; Account account = new Account(); identity = new Identity(account.EntityName, id); accountDocument = (AccountDocument)_entity.GetDocument(identity, _emptyToken, _context.Config); if (accountDocument.LogState == LogState.Deleted) { return(null); } if (accountDocument.addresses.documents.Count == 0) { return(null); } Document document = accountDocument.addresses.documents[0]; List <SyncFeedEntryLink> links; result.Payload = GetTransformedPayload(document, out links); string taUuid = GetTradingAccountUuid(accountDocument.Id); if (!String.IsNullOrEmpty(taUuid)) { SyncFeedEntryLink tradingAccountLink = SyncFeedEntryLink.CreateRelatedLink( String.Format("{0}{1}('{2}')", _context.DatasetLink, SupportedResourceKinds.tradingAccounts.ToString(), accountDocument.Id), SupportedResourceKinds.tradingAccounts.ToString(), _tradingAccountUuidPayloadPath, taUuid); links.Add(tradingAccountLink); } result.SyncLinks = links; result.Id = String.Format("{0}{1}('{2}')", _context.DatasetLink, _resourceKind.ToString(), id); result.Title = String.Format("{0}: {1}", _resourceKind.ToString(), id); result.Updated = DateTime.Now; return(result); }
public virtual SyncFeedEntry GetFeedEntry(string id) { SyncFeedEntry result = new SyncFeedEntry(); result.Payload = PayloadFactory.CreatePayload(_resourceKind); Identity identity; Document document; identity = GetIdentity(id); document = _entity.GetDocument(identity, _emptyToken, _context.Config); if (document.LogState == LogState.Deleted) { return(null); } List <SyncFeedEntryLink> links; result.Payload = GetTransformedPayload(document, out links); result.Id = String.Format("{0}{1}('{2}')", _context.DatasetLink, _resourceKind.ToString(), id); result.Title = String.Format("{0}: {1}", _resourceKind.ToString(), id); result.Updated = DateTime.Now; result.SyncLinks = links; return(result); }
public override SyncFeedEntry GetFeedEntry(string id) { SyncFeedEntry result = new SyncFeedEntry(); result.Payload = PayloadFactory.CreatePayload(_resourceKind); Identity identity; AccountDocument accountDocument; Account account = new Account(); string accountId; if (id.EndsWith(Sage.Integration.Northwind.Application.API.Constants.PhoneIdPostfix)) { accountId = id.Replace(Sage.Integration.Northwind.Application.API.Constants.PhoneIdPostfix, ""); } else if (id.EndsWith(Sage.Integration.Northwind.Application.API.Constants.FaxIdPostfix)) { accountId = id.Replace(Sage.Integration.Northwind.Application.API.Constants.FaxIdPostfix, ""); } else { return(null); } identity = new Identity(account.EntityName, accountId); accountDocument = (AccountDocument)_entity.GetDocument(identity, _emptyToken, _context.Config); if (accountDocument.LogState == LogState.Deleted) { return(null); } if (accountDocument.addresses.documents.Count == 0) { return(null); } Document document = null; foreach (Document phoneDoc in accountDocument.phones.documents) { if (phoneDoc.Id.Equals(id, StringComparison.InvariantCultureIgnoreCase)) { document = phoneDoc; break; } } if (document == null) { return(null); } List <SyncFeedEntryLink> links; result.Payload = GetTransformedPayload(document, out links); string taUuid = GetTradingAccountUuid(accountDocument.Id); if (!String.IsNullOrEmpty(taUuid)) { SyncFeedEntryLink tradingAccountLink = SyncFeedEntryLink.CreateRelatedLink( String.Format("{0}{1}('{2}')", _context.DatasetLink, SupportedResourceKinds.tradingAccounts.ToString(), accountDocument.Id), SupportedResourceKinds.tradingAccounts.ToString(), _tradingAccountUuidPayloadPath, taUuid); links.Add(tradingAccountLink); } result.SyncLinks = links; result.Id = String.Format("{0}{1}('{2}')", _context.DatasetLink, _resourceKind.ToString(), id); result.Title = String.Format("{0}: {1}", _resourceKind.ToString(), id); result.Updated = DateTime.Now; return(result); }