ScoringService.cs
Version Info: This topic applies to Episerver.ConnectForMarketingAutomation 4.0.0 and lower. For later versions, see Sample Connector - IMarketingConnector.
using System.Collections.Generic;
using EPiServer.MarketingAutomationIntegration.Domain;
using EPiServer.MarketingAutomationIntegration.Services;
namespace DemoConnector.Services
{
/// <summary>
/// Interface for working with provider scoring.
/// </summary>
/// <remarks>
/// If you do not want to support scoring and have the "Scoring Model" selector removed
/// from the edit visitor group page, GetScoringRank should throw NotImplementedException.
/// </remarks>
public class ScoringService : IScoringService
{
/// <summary>
/// Return a collection of ScoringModel objects.
/// </summary>
/// <returns>List of all scoring models.</returns>
/// <remarks>
/// This demo returns a list that contains a single scoring model.
/// </remarks>
public IEnumerable<ScoringModel> GetAllScoringModels()
{
var sm = new ScoringModel()
{
Id = 1,
Description = "Demo Scoring Model 1",
Name = "Demo Scoring Model 1"
};
var list = new List<ScoringModel>();
list.Add(sm);
return list;
}
/// <summary>
/// Return the list of scoring types.
/// </summary>
/// <returns>List of all scoring types.</returns>
public IEnumerable<KeyValuePair<string, string>> GetAllScoringTypes()
{
return new List<KeyValuePair<string, string>>()
{
new KeyValuePair<string, string>("Score Type 1", "Score Type 1"),
new KeyValuePair<string, string>("Score Type 2", "Score Type 2"),
new KeyValuePair<string, string>("Score Type 3", "Score Type 3")
};
}
/// <summary>
/// Return a collection of ScoringModelValues for the modelId.
/// </summary>
/// <param name="profile">Profile type to filter by.</param>
/// <param name="modelId">ModelID to filter by.</param>
/// <returns>The scoring profile that matches the parameter filters.</returns>
/// <remarks>
/// Because you have only one modelId, always return the same collection.
/// </remarks>
public IEnumerable<ScoringModelValues> GetScoringForProfile(Profile profile, int modelId)
{
return new List<ScoringModelValues>()
{
new ScoringModelValues() {Id=1, Name="ScoringModel 1", Rank="One" },
new ScoringModelValues() { Id = 2, Name = "ScoringModel 2", Rank = "Two" },
new ScoringModelValues() { Id = 3, Name = "ScoringModel 3", Rank = "Three" }
};
}
/// <summary>
/// Returns the scoring rank collection.
/// </summary>
/// <param name="scoringModelId">Scoring model Id to filter against.</param>
/// <returns>List of scoring ranks.</returns>
/// <remarks>
/// Throw NotImplementedException if your connector does not support scoring ranks.
/// </remarks>
public IEnumerable<KeyValuePair<string, string>> GetScoringRank(string scoringModelId)
{
List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>();
return new List<KeyValuePair<string, string>>()
{
new KeyValuePair<string, string>("Rank 1", "Rank1"),
new KeyValuePair<string, string>("Rank 2", "Rank2"),
new KeyValuePair<string, string>("Rank 3", "Rank3")
};
}
}
}
Related topics
- AuthenticationService.cs
- DataList.cs
- InProgram.cs
- ListService.cs
- NamespaceDoc.cs
- ProfileService.cs
- Program.cs
- ProgramService.cs
- Provider.cs
- ProviderServices.cs
- app.config
- module.config
- packages.config
Last updated: Dec 14, 2015