Creating the manager

The manager operates on job application providers which inherit from JobsDataProviderBase. The component to use when you want to work with the model is the manager.

To implement the manager, perform the following:

  1. From the context menu of the solution, click Add » New Item...

  2. In the left pane, select Visual C# » Code.

  3. Click Class and in the Name input field, enter JobsManager.

  4. Open the file JobsManager.cs and add the following namespaces:

    using System.Linq;
    using Jobs.Configuration;
    using Jobs.Model;
    using Telerik.Sitefinity;
    using Telerik.Sitefinity.Configuration;
    using Telerik.Sitefinity.Data;
    using Telerik.Sitefinity.GenericContent.Model;
    using Telerik.Sitefinity.Modules.GenericContent;
  5. Change the class definition to:

    public class JobsManager : ContentManagerBase<JobsDataProviderBase>, IContentLifecycleManager<JobApplication>
    {
     
    }
  6. Define the following constructors:

    public JobsManager()
        : this(null)
    {
    }
     
    public JobsManager(string providerName)
        : base(providerName)
    {
    }
     
    public JobsManager(string providerName, string transactionName)
        : base(providerName, transactionName)
    {
    }
  7. Specify the module name in the following way:

    public override string ModuleName
    {
        get { return JobsModule.ModuleName; }
    }
  8. Define the provider by pasting the following code:

    protected override ConfigElementDictionary<string, DataProviderSettings> ProvidersSettings
    {
        get { return Config.Get<JobsConfig>().Providers; }
    }
     
    protected override GetDefaultProvider DefaultProviderDelegate
    {
        get { return () => Config.Get<JobsConfig>().DefaultProvider; }
    }
  9. Define the GetManager method in the following way:

    public static JobsManager GetManager()
    {
        return ManagerBase<JobsDataProviderBase>.GetManager<JobsManager>();
    }
     
    public static JobsManager GetManager(string providerName)
    {
        return ManagerBase<JobsDataProviderBase>.GetManager<JobsManager>(providerName);
    }
     
    public static JobsManager GetManager(string providerName, string transactionName)
    {
        return ManagerBase<JobsDataProviderBase>.GetManager<JobsManager>(providerName, transactionName);
    }
  10. Implement the CRUD operations by pasting the following code:

    public virtual JobApplication CreateJobApplication()
    {
        return this.Provider.CreateJobApplication();
    }
     
    public virtual JobApplication CreateJobApplication(Guid id)
    {
        return this.Provider.CreateJobApplication(id);
    }
     
    public virtual IQueryable<JobApplication> GetJobApplications()
    {
        return this.Provider.GetJobApplications();
    }
     
    public virtual JobApplication GetJobApplication(Guid id)
    {
        return this.Provider.GetJobApplication(id);
    }
     
    public virtual void DeleteJobApplication(JobApplication application)
    {
        this.Provider.DeleteJobApplication(application);
    }
  11. Override the GetItems method by pasting the following code:

    public override IQueryable<TItem> GetItems<TItem>()
    {
        if (typeof(JobApplication).IsAssignableFrom(typeof(TItem)))
            return this.GetJobApplications() as IQueryable<TItem>;
        if (typeof(TItem) == typeof(Comment))
            return null;
        throw new NotSupportedException();
    }
  12. Implement the members required by the IContentLifecycleManager interface.

    Although the Jobs module does not support content lifecycle, the implementation of the interface is mandatory for the manager class. Following is the default implementation of the members:

    public JobApplication CheckIn(JobApplication item)
    {
        throw new NotImplementedException();
    }
     
    public JobApplication CheckOut(JobApplication item)
    {
        throw new NotImplementedException();
    }
     
    public void Copy(JobApplication source, JobApplication destination)
    {
        throw new NotImplementedException();
    }
     
    public JobApplication Edit(JobApplication item)
    {
        throw new NotImplementedException();
    }
     
    public Guid GetCheckedOutBy(JobApplication item)
    {
        throw new NotImplementedException();
    }
     
    public JobApplication GetLive(JobApplication cnt)
    {
        throw new NotImplementedException();
    }
     
    public JobApplication GetMaster(JobApplication cnt)
    {
        throw new NotImplementedException();
    }
     
    public JobApplication GetTemp(JobApplication cnt)
    {
        throw new NotImplementedException();
    }
     
    public bool IsCheckedOut(JobApplication item)
    {
        throw new NotImplementedException();
    }
     
    public bool IsCheckedOutBy(JobApplication item, Guid userId)
    {
        throw new NotImplementedException();
    }
     
    public JobApplication Publish(JobApplication item)
    {
        throw new NotImplementedException();
    }
     
    public JobApplication Schedule(JobApplication item, DateTime publicationDate, DateTime? expirationDate)
    {
        throw new NotImplementedException();
    }
     
    public JobApplication Unpublish(JobApplication item)
    {
        throw new NotImplementedException();
    }
     
    public Content CheckIn(Content item)
    {
        throw new NotImplementedException();
    }
     
    public Content CheckOut(Content item)
    {
        throw new NotImplementedException();
    }
     
    public void Copy(Content source, Content destination)
    {
        throw new NotImplementedException();
    }
     
    public Content Edit(Content item)
    {
        throw new NotImplementedException();
    }
     
    public Guid GetCheckedOutBy(Content item)
    {
        throw new NotImplementedException();
    }
     
    public Content GetLive(Content cnt)
    {
        throw new NotImplementedException();
    }
     
    public Content GetMaster(Content cnt)
    {
        throw new NotImplementedException();
    }
     
    public Content GetTemp(Content cnt)
    {
        throw new NotImplementedException();
    }
     
    public bool IsCheckedOut(Content item)
    {
        throw new NotImplementedException();
    }
     
    public bool IsCheckedOutBy(Content item, Guid userId)
    {
        throw new NotImplementedException();
    }
     
    public Content Publish(Content item)
    {
        throw new NotImplementedException();
    }
     
    public Content Schedule(Content item, DateTime publicationDate, DateTime? expirationDate)
    {
        throw new NotImplementedException();
    }
     
    public Content Unpublish(Content item)
    {
        throw new NotImplementedException();
    }

JobsManager inherits from ContentManagerBase and IContentLifecycleManager. ContentManagerBase is the default base class for content-based data managers. JobsDataProviderBase specifies the base class of the providers that this manager works with.ConfigElementDictionary<string, DataProviderSettings> ProvidersSettings is a dictionary containing available providers, which is defined in JobsConfig. JobsModule and JobsConfig are defined in Localization and Creating the module.

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