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

60 lines
1.7 KiB
C#
Raw Normal View History

2024-01-01 04:56:10 +00:00
using BotSharp.Abstraction.Conversations.Models;
namespace BotSharp.Plugin.MongoStorage.Models;
public class StateMongoElement
{
public string Key { get; set; }
2024-03-26 21:57:13 +00:00
public bool Versioning { get; set; }
2024-01-01 04:56:10 +00:00
public List<StateValueMongoElement> Values { get; set; }
2024-01-02 17:40:08 +00:00
public static StateMongoElement ToMongoElement(StateKeyValue state)
2024-01-01 04:56:10 +00:00
{
return new StateMongoElement
{
Key = state.Key,
2024-03-26 21:57:13 +00:00
Versioning = state.Versioning,
2024-01-01 04:56:10 +00:00
Values = state.Values?.Select(x => StateValueMongoElement.ToMongoElement(x))?.ToList() ?? new List<StateValueMongoElement>()
};
}
2024-01-02 17:40:08 +00:00
public static StateKeyValue ToDomainElement(StateMongoElement state)
2024-01-01 04:56:10 +00:00
{
2024-01-02 17:40:08 +00:00
return new StateKeyValue
2024-01-01 04:56:10 +00:00
{
Key = state.Key,
2024-03-26 21:57:13 +00:00
Versioning = state.Versioning,
2024-01-02 17:40:08 +00:00
Values = state.Values?.Select(x => StateValueMongoElement.ToDomainElement(x))?.ToList() ?? new List<StateValue>()
2024-01-01 04:56:10 +00:00
};
}
}
public class StateValueMongoElement
{
public string Data { get; set; }
2024-03-26 21:57:13 +00:00
public string MessageId { get; set; }
public bool Active { get; set; }
2024-01-01 04:56:10 +00:00
public DateTime UpdateTime { get; set; }
2024-01-02 17:40:08 +00:00
public static StateValueMongoElement ToMongoElement(StateValue element)
2024-01-01 04:56:10 +00:00
{
return new StateValueMongoElement
{
Data = element.Data,
2024-03-26 21:57:13 +00:00
MessageId = element.MessageId,
Active = element.Active,
2024-01-01 04:56:10 +00:00
UpdateTime = element.UpdateTime
};
}
2024-01-02 17:40:08 +00:00
public static StateValue ToDomainElement(StateValueMongoElement element)
2024-01-01 04:56:10 +00:00
{
2024-01-02 17:40:08 +00:00
return new StateValue
2024-01-01 04:56:10 +00:00
{
Data = element.Data,
2024-03-26 21:57:13 +00:00
MessageId = element.MessageId,
Active = element.Active,
2024-01-01 04:56:10 +00:00
UpdateTime = element.UpdateTime
};
}
}