Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

ProgramService.cs

Version InfoThis topic applies to Episerver.ConnectForMarketingAutomation 4.0.0 and lower. For later versions, see Sample Connector - IMarketingConnector

using System;
using System.Collections.Generic;
using EPiServer.MarketingAutomationIntegration.Core.Enums;
using EPiServer.MarketingAutomationIntegration.Domain;
using EPiServer.MarketingAutomationIntegration.Services;
using DemoConnector.Models;

namespace DemoConnector.Services
{
    /// <summary>
    /// Interface for working with provider programs. 
    /// </summary>
    /// <remarks>
    /// If you do not want to support programs and have the "Program" selector removed 
    /// from the edit visitor group page, GetProgramsByProfileAndStatus should throw NotImplementedException. 
    /// </remarks>
    public class ProgramService : IProgramService
    {
        /// <summary>
        /// Implement this method if your connector  
        /// can create program objects on the end point. 
        /// </summary>
        /// <param name="newProgram">New program to create.</param>
        /// <remarks>
        /// The marketing automation interface framework does not calls this method. 
        /// It is supplied as a convenience only, and it is up to your implementation 
        /// to decide to implement and call it.
        /// </remarks>
        public void CreateProgram(IProgram newProgram)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Not called by the marketing automation interface framework.
        /// </summary>
        /// <returns>List of Programs</returns>
        public IEnumerable<IProgram> GetAllPrograms()
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Returns a list of IInProgram objects which describe a program.
        /// </summary>
        /// <param name="profile">Filter programs by their profile.</param>
        /// <param name="status">Filter programs by their Active/Inactive state.</param>
        /// <returns>List of programs.</returns>
        /// <remarks>
        /// Throw NotImplementedException if your connector will not support programs.
        /// </remarks>
        public IEnumerable<IInProgram> GetProgramsByProfileAndStatus(Profile profile, ProgramStatus status)
        {
            var list = new List<IInProgram>();
            list.Add(new InProgram() { ProgramId=1, EnteredDate=DateTime.MinValue, ExitedDate=DateTime.MaxValue});
            list.Add(new InProgram() { ProgramId = 2, EnteredDate = DateTime.MinValue, ExitedDate = DateTime.MaxValue });
            list.Add(new InProgram() { ProgramId = 3, EnteredDate = DateTime.MinValue, ExitedDate = DateTime.MaxValue });
            return list;
        }

        /// <summary>
        /// Returns a list of programs for the visitor group criteria page.
        /// </summary>
        /// <param name="status">Filter programs by their Active/Inactive state.</param>
        /// <returns>List of programs.</returns>
        public IEnumerable<IProgram> GetProgramsByStatus(ProgramStatus status)
        {
            var list = new List<IProgram>();
            list.Add(new Program() {Id=1,ListId=41, Name="Program 1", Notes="Great Program!", State=ProgramState.Complete });
            list.Add(new Program() { Id = 2, ListId = 42, Name = "Program 2", Notes = "Great Program!", State = ProgramState.Running });
            list.Add(new Program() { Id = 3, ListId = 43, Name = "Program 3", Notes = "Great Program!", State = ProgramState.Scheduled });
            return list;
        }
    }
}

Related topics

Last updated: Dec 14, 2015