[DEV] How to add a custom form to permit to search some data from database

Topics: Customizing Orchard
May 23, 2013 at 6:45 AM
Edited May 23, 2013 at 6:46 AM

I create my first module custPoi. The idea is to have a module permitting to describe a point of interrest with latitude, longitude, name, street, city.

So ok I find a way, and I have a page with the all POI.
I would like to have a first page proposing a submit form permitting to choose the type of POI to display and the submit action redirect to the new page and I display the POI on a map.
I already did this action by using ASP.NET MVC with webAPI. I try to "upload" this code in Orchard.

Is there any sample or document about how to request the database, how am I supposed to modify the design code to avoid to break Orchard, I would like to be sure to follow properly the development guideline from Orchard.

Any input?
May 23, 2013 at 3:08 PM
You can query the database injecting an IRepository<T> into your controller or service class. E.g. if you have an entity class called POI, inject IRepository<POI>:
private IRepository<POI> _poiRepository;
public POIService(IRepository<POI> poiRepository) {
   _poiRepository = poiRepository;

public IEnumerable<POI> FindPOI(double latitude, double longitude, string name, string city, string street) {
   return _poiRepository.Fetch(x => x.Latitude == latitude && x.Longitude == longitude); // Most likely you are looking for POI's within a certain distance of the specified coordinates or place, but you get the idea.