Continued from Part I outlining how Entity Service can be consumed by SPEAK.
EntityService in Sitecore.Services.Client
We opted for EntityService as opposed to ItemService as it allowed us to serve up custom, lean Models of Items and Fields. Containing only properties required for the Module providing we implement EntityIdenitity in the class definition.
One issue we did lose development time over was defining the itemId property. Without it being defined and exact casing it breaks the integration between SCC and the PageCode. Naming as such did piss off Resharper.
To ensure the developer is presented with enough information I implemented the Field’s Template Name and Id, for quick navigation, the fields current Value and it’s Standard Value. To ensure the fields were ordered to match that in the Content Editor, the Model holds the properties SectionSortOrder and SortOrder. Finally, exposing a property defining if the Field is a Standard Field means these fields can be hidden from view if so desired.
One of the good things of SSC is that the Controller can be kept lean by implementing a repository pattern based on Sitecore’s IRepository interface. Thus keeping the useful Create, Read, Update, Delete functions in a highly accessible area of the Solution Architecture.
Even if not all functions of the IRepository are required, they must be implemented.
For an intro to EntityService and Sitecore.Services.Client Mike has written a great post about it