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

53 lines
1.4 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; }
2024-01-29 22:14:17 +00:00
public string Type { get; set; }
2024-04-03 14:47:32 +00:00
public string FieldType { 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,
2024-01-29 22:14:17 +00:00
RedirectTo = routingRule.RedirectTo,
Type = routingRule.Type,
2024-04-03 14:47:32 +00:00
FieldType = routingRule.FieldType
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,
2024-01-29 22:14:17 +00:00
RedirectTo = rule.RedirectTo,
Type = rule.Type,
2024-04-03 14:47:32 +00:00
FieldType= rule.FieldType
2023-09-18 23:14:24 +00:00
};
}
2024-04-03 14:47:32 +00:00
public override string ToString()
{
return $"{Field} - {FieldType}, Required: {Required} ({Type})";
}
2023-09-18 23:14:24 +00:00
}