Implementing the backend service

To create the backend service, you must perform the following:

  1. From the context menu of the folder Web » Services in the LocationsModule project, click Add » Class.
  2. Name the class file LocationsBackendService.cs and click Add.
  3. Open the file LocationsBackendService.cs.
  4. Add the following using statments:

    • using Telerik.Sitefinity.Modules;
    • using LocationsModule.Model;
    • using LocationsModule.Web.Services.Data;
    • using LocationsModule.Data;
    • using Telerik.Sitefinity.Modules.GenericContent;
  5. Make the LocationsBackendService class inherit the ContentServiceBase<LocationItem, LocationItemViewModel, LocationsManager> class:

    public class LocationsBackendService : ContentServiceBase<LocationItem, LocationItemViewModel, LocationsManager>
    {
    }

  6. Implement the abstract members of the ContentServiceBase in the following way:

    public override IQueryable<LocationItem> GetChildContentItems(Guid parentId, string providerName)
    {
        throw new NotImplementedException();
    }
     
    public override LocationItem GetContentItem(Guid id, string providerName)
    {
        return this.GetManager(providerName).GetLocation(id);
    }
     
    public override IQueryable<LocationItem> GetContentItems(string providerName)
    {
        return this.GetManager(providerName).GetLocations();
    }
     
    public override LocationsManager GetManager(string providerName)
    {
        return LocationsManager.GetManager(providerName);
    }
     
    public override LocationItem GetParentContentItem(Guid id, string providerName)
    {
        throw new NotImplementedException();
    }
     
    public override IEnumerable<LocationItemViewModel> GetViewModelList(IEnumerable<LocationItem> contentList, ContentDataProviderBase dataProvider)
    {
        var list = new List<LocationItemViewModel>();
     
        foreach (var location in contentList)
            list.Add(new LocationItemViewModel(location, dataProvider));
     
        return list;
    }

Related topics:

Feedback

How useful is this article?

Tell us more

Submit
Your message was successfully sent.

We appreciate your feedback.

Your message could not be sent.

OK