BotSharp/src/Plugins/BotSharp.Plugin.MongoStorage/Models/RoutingRuleMongoElement.cs

38 lines
1 KiB
C#
Raw Normal View History

2023-09-18 23:14:24 +00:00
using BotSharp.Abstraction.Routing.Models;
namespace BotSharp.Plugin.MongoStorage.Models;
2023-09-19 18:20:41 +00:00
public class RoutingRuleMongoElement
2023-09-18 23:14:24 +00:00
{
public string Field { get; set; }
public bool Required { get; set; }
public Guid? RedirectTo { get; set; }
2023-09-19 18:20:41 +00:00
public RoutingRuleMongoElement()
2023-09-18 23:14:24 +00:00
{
}
2023-09-19 18:20:41 +00:00
public static RoutingRuleMongoElement ToMongoElement(RoutingRule routingRule)
2023-09-18 23:14:24 +00:00
{
2023-09-19 18:20:41 +00:00
return new RoutingRuleMongoElement
2023-09-18 23:14:24 +00:00
{
Field = routingRule.Field,
Required = routingRule.Required,
RedirectTo = !string.IsNullOrEmpty(routingRule.RedirectTo) ? Guid.Parse(routingRule.RedirectTo) : null
};
}
2023-09-19 18:20:41 +00:00
public static RoutingRule ToDomainElement(string agentId, string agentName, RoutingRuleMongoElement rule)
2023-09-18 23:14:24 +00:00
{
return new RoutingRule
{
AgentId = agentId,
AgentName = agentName,
Field = rule.Field,
Required = rule.Required,
RedirectTo = rule.RedirectTo?.ToString()
};
}
}