41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
using LiteDB;
|
|
using System.Globalization;
|
|
using System.Numerics;
|
|
using static DeluxeBackend.Enums;
|
|
namespace DeluxeBackend.Models
|
|
{
|
|
public class Message
|
|
{
|
|
[BsonId]
|
|
public long Id { get; set; }
|
|
[BsonRef("accounts")]
|
|
public required Account Player { get; set; }
|
|
[BsonRef("accounts")]
|
|
public required Account FromPlayer { get; set; }
|
|
public DateTime SentTime { get; set; } = DateTime.UtcNow;
|
|
public required MessageType Type { get; set; }
|
|
public string Data { get; set; } = string.Empty;
|
|
|
|
public Dictionary<string, object> ToDictionary()
|
|
{
|
|
string daya = string.Empty;
|
|
if (Data != null)
|
|
{
|
|
daya = Data;
|
|
}
|
|
var data = new Dictionary<string, object>
|
|
{
|
|
["Id"] = Id,
|
|
["FromPlayerId"] = FromPlayer.Id,
|
|
["SentTime"] = SentTime.ToString("o", CultureInfo.InvariantCulture),
|
|
["Type"] = (int)Type,
|
|
["Data"] = daya
|
|
|
|
};
|
|
|
|
return data;
|
|
}
|
|
|
|
}
|
|
}
|