rename mongo routing rule element

This commit is contained in:
Jicheng Lu 2023-09-19 13:20:41 -05:00
parent d238064af9
commit 114bae3c2a
3 changed files with 11 additions and 11 deletions

View file

@ -15,7 +15,7 @@ public class AgentCollection : MongoBase
public bool AllowRouting { get; set; }
public bool Disabled { get; set; }
public List<string> Profiles { get; set; }
public List<RoutingRuleElement> RoutingRules { get; set; }
public List<RoutingRuleMongoElement> RoutingRules { get; set; }
public DateTime CreatedTime { get; set; }
public DateTime UpdatedTime { get; set; }

View file

@ -2,20 +2,20 @@ using BotSharp.Abstraction.Routing.Models;
namespace BotSharp.Plugin.MongoStorage.Models;
public class RoutingRuleElement
public class RoutingRuleMongoElement
{
public string Field { get; set; }
public bool Required { get; set; }
public Guid? RedirectTo { get; set; }
public RoutingRuleElement()
public RoutingRuleMongoElement()
{
}
public static RoutingRuleElement ToMongoElement(RoutingRule routingRule)
public static RoutingRuleMongoElement ToMongoElement(RoutingRule routingRule)
{
return new RoutingRuleElement
return new RoutingRuleMongoElement
{
Field = routingRule.Field,
Required = routingRule.Required,
@ -23,7 +23,7 @@ public class RoutingRuleElement
};
}
public static RoutingRule ToDomainElement(string agentId, string agentName, RoutingRuleElement rule)
public static RoutingRule ToDomainElement(string agentId, string agentName, RoutingRuleMongoElement rule)
{
return new RoutingRule
{

View file

@ -48,7 +48,7 @@ public class MongoRepository : IBotSharpRepository
AllowRouting = x.AllowRouting,
Profiles = x.Profiles,
RoutingRules = x.RoutingRules?
.Select(r => RoutingRuleElement.ToDomainElement(x.Id.ToString(), x.Name, r))?
.Select(r => RoutingRuleMongoElement.ToDomainElement(x.Id.ToString(), x.Name, r))?
.ToList() ?? new List<RoutingRule>(),
CreatedDateTime = x.CreatedTime,
UpdatedDateTime = x.UpdatedTime
@ -218,8 +218,8 @@ public class MongoRepository : IBotSharpRepository
Disabled = x.Disabled,
Profiles = x.Profiles,
RoutingRules = x.RoutingRules?
.Select(r => RoutingRuleElement.ToMongoElement(r))?
.ToList() ?? new List<RoutingRuleElement>(),
.Select(r => RoutingRuleMongoElement.ToMongoElement(r))?
.ToList() ?? new List<RoutingRuleMongoElement>(),
CreatedTime = x.CreatedDateTime,
UpdatedTime = x.UpdatedDateTime
}).ToList();
@ -420,7 +420,7 @@ public class MongoRepository : IBotSharpRepository
{
if (rules.IsNullOrEmpty()) return;
var ruleElements = rules.Select(x => RoutingRuleElement.ToMongoElement(x)).ToList();
var ruleElements = rules.Select(x => RoutingRuleMongoElement.ToMongoElement(x)).ToList();
var filter = Builders<AgentCollection>.Filter.Eq(x => x.Id, Guid.Parse(agentId));
var update = Builders<AgentCollection>.Update
.Set(x => x.RoutingRules, ruleElements)
@ -486,7 +486,7 @@ public class MongoRepository : IBotSharpRepository
.Set(x => x.Disabled, agent.Disabled)
.Set(x => x.AllowRouting, agent.AllowRouting)
.Set(x => x.Profiles, agent.Profiles)
.Set(x => x.RoutingRules, agent.RoutingRules.Select(x => RoutingRuleElement.ToMongoElement(x)).ToList())
.Set(x => x.RoutingRules, agent.RoutingRules.Select(x => RoutingRuleMongoElement.ToMongoElement(x)).ToList())
.Set(x => x.Instruction, agent.Instruction)
.Set(x => x.Templates, agent.Templates)
.Set(x => x.Functions, agent.Functions)