My requirement is to store the result of a "rendered" DCP. With DXA since the views will do the rendering portion, my idea was to get the "DCP" from Broker and then get the corresponding partial view in DXA, render it and then store the resultant string. Here are the steps I have -
Get the Component id as a part of the URL request like - /devControls/RenderDCP/tcm_x-y
Get the Entity model using the following call -
id = id.Replace("_", ":");
EntityModel model = ContentProvider.GetEntityModel(id, WebRequestContext.Localization);
Everything looks fine theoretically. However, I am failing in the second step itself. When I debug my code, Item tcm_x-y not found. However, I see the item in my Broker DB. Any thoughts on how to proceed with this?
In DXA, the identifier for an Entity based on a DCP has the format <Component Item ID>-<Template Item ID>. For example: for a DCP based on Component tcm:123-456 and Template tcm:123-678-32, the DXA Entity will have ID 456-678.
Note that the DXA identifier doesn't contain a context Publication ID. That is why a Localization instance (which corresponds to a Publication in Tridion) has to be provided too.