Database Reference
In-Depth Information
Figure 7-10.
The scrolling Product and Product Trail page
In the
ConsumptionController
, you will take a look at the
CreateUserProductViewRel
method to see how the
process begins inside the controller. The controller method first saves the view and then returns the complete history
of views using the
getProductTrail
, which can be found in the ProductService class (Listing 7-42). The process is
started when the
createUserProductViewRel
function is called, which is located in
graphstory.js.
Listing 7-42.
getProductTrail
in the
ProductService
public List<MappedProductUserViews> getProductTrail(string username)
{
List<MappedProductUserViews> mappedProductUserViews = _graphClient.Cypher
.Match("(u:User { username: {username} })-[r:VIEWED]->(p)")
.WithParam("username", username)
.Return(() => Return.As<MappedProductUserViews>("{ title: p.title, "+
"dateAsStr: r.dateAsStr }"))
.OrderByDescending("r.timestamp")
.Results.ToList();
return mappedProductUserViews;
}