/// <summary> /// Get entity model data object. /// </summary> public EntityModelData GetEntityModelData(string entityId, Localization localization) { try { EntityModelRequest request = new EntityModelRequest { EntityId = entityId, CmUriScheme = localization.CmUriScheme, PublicationId = int.Parse(localization.Id), Binder = _binder }; ModelServiceResponse <EntityModelData> response = _modelServiceClient.PerformRequest <EntityModelData>(request); if (response.Response != null) { response.Response.SerializationHashCode = response.Hashcode; } return(response.Response); } catch (ModelServiceException e) { Log.Error("{0} returned an unexpected response for URL '{1}':\n{2} ", ModelServiceName, _modelServiceClient.ModelServiceBaseUri, e.Message); throw new DxaException($"{ModelServiceName} returned an unexpected response.", e); } catch (ItemNotFoundException) { return(null); } }
public string GetContent(string uri, string templateUri = "") { LoggerService.Debug(">>DD4T.Providers.DxaModelService::GetContent({0})", LoggingCategory.Performance, uri); LoggerService.Debug(">>DD4T.Providers.DxaModelService::GetContent({0})", LoggingCategory.Performance, uri); TcmUri tcmUri = new TcmUri(uri); TcmUri templateTcmUri = new TcmUri(templateUri); EntityModelRequest request = new EntityModelRequest { PublicationId = PublicationId, DataModelType = DataModelType.DD4T, DcpType = DcpType.HIGHEST_PRIORITY, ComponentId = tcmUri.ItemId }; if (!string.IsNullOrEmpty(templateUri)) { request.TemplateId = templateTcmUri.ItemId; } try { var response = ModelServiceClient.PerformRequest <IDictionary <string, object> >(request); return(response.Response["Content"] as string); } catch { } return(null); }