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

42 lines
1.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-10-25 20:09:21 +00:00
[BsonIgnoreExtraElements]
2023-09-19 18:20:41 +00:00
public class RoutingRuleMongoElement
2023-09-18 23:14:24 +00:00
{
public string Field { get; set; }
2023-10-16 21:37:01 +00:00
public string Description { get; set; }
2023-09-18 23:14:24 +00:00
public bool Required { get; set; }
public string? RedirectTo { get; set; }
2023-09-18 23:14:24 +00:00
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,
2023-10-16 21:37:01 +00:00
Description = routingRule.Description,
2023-09-18 23:14:24 +00:00
Required = routingRule.Required,
RedirectTo = routingRule.RedirectTo
2023-09-18 23:14:24 +00:00
};
}
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,
2023-10-16 21:37:01 +00:00
Description = rule.Description,
2023-09-18 23:14:24 +00:00
Required = rule.Required,
RedirectTo = rule.RedirectTo
2023-09-18 23:14:24 +00:00
};
}
}