Database Reference
In-Depth Information
else
{
ViewBag.error = graphStory.error;
return View("~/Views/Home/Index.cshtml");
}
}
}
Adding a User
Each domain object must have a corresponding interface and implementation in order to manage the respective
domain object. As a part of the architecture, each interface is part of the main service layer created with the
GraphStoryService class, which implements the GraphStoryInterface . In addition, each of the implementation
classes adds the IGraphClient in order to have access to the injected GraphClient via the Neo4jModule.
In this case, the UserService class implements the methods found in UserInterface , both of which are located
in the Service folder. The UserInterface is shown in Listing 7-17.
Listing 7-17. The UserInterface Class
public interface UserInterface
{
User getByUserName(string username);
GraphStory login(GraphStory graphStory);
GraphStory save(GraphStory graphStory);
User update(User user);
List<User> following(string username);
MappedUserLocation getUserLocation(String currentusername);
List<User> searchNotFollowing(String currentusername, String username);
List<User> follow(String currentusername, String username);
List<User> unfollow(String currentusername, String username);
}
although the chapter does not dive into the details of the GraphStoryService and GraphStoryInterface
classes, they will be reused throughout the application. as noted previously, the GraphStoryService class is used for
convenience in order to have access to each specific interface by using a single top-level service interface.
Note
In the UserService class, you will notice several implemented methods to manage the User object. To add the
User object to the database, use the save method, which will first check to see if a username has already been added
to the database. If no user exists, then the user will be saved to the database, as shown in Listing 7-18.
 
 
Search WWH ::




Custom Search