Some checks failed
Build Test Deploy / build-test (push) Has been cancelled
Build Test Deploy / authority-container (push) Has been cancelled
Build Test Deploy / docs (push) Has been cancelled
Build Test Deploy / deploy (push) Has been cancelled
Docs CI / lint-and-preview (push) Has been cancelled
55 lines
1.5 KiB
C#
55 lines
1.5 KiB
C#
using MongoDB.Bson.Serialization.Attributes;
|
|
|
|
namespace StellaOps.Feedser.Storage.Mongo.JpFlags;
|
|
|
|
[BsonIgnoreExtraElements]
|
|
public sealed class JpFlagDocument
|
|
{
|
|
[BsonId]
|
|
[BsonElement("advisoryKey")]
|
|
public string AdvisoryKey { get; set; } = string.Empty;
|
|
|
|
[BsonElement("sourceName")]
|
|
public string SourceName { get; set; } = string.Empty;
|
|
|
|
[BsonElement("category")]
|
|
[BsonIgnoreIfNull]
|
|
public string? Category { get; set; }
|
|
|
|
[BsonElement("vendorStatus")]
|
|
[BsonIgnoreIfNull]
|
|
public string? VendorStatus { get; set; }
|
|
|
|
[BsonElement("recordedAt")]
|
|
public DateTime RecordedAt { get; set; }
|
|
}
|
|
|
|
internal static class JpFlagDocumentExtensions
|
|
{
|
|
public static JpFlagDocument FromRecord(JpFlagRecord record)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(record);
|
|
|
|
return new JpFlagDocument
|
|
{
|
|
AdvisoryKey = record.AdvisoryKey,
|
|
SourceName = record.SourceName,
|
|
Category = record.Category,
|
|
VendorStatus = record.VendorStatus,
|
|
RecordedAt = record.RecordedAt.UtcDateTime,
|
|
};
|
|
}
|
|
|
|
public static JpFlagRecord ToRecord(this JpFlagDocument document)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(document);
|
|
|
|
return new JpFlagRecord(
|
|
document.AdvisoryKey,
|
|
document.SourceName,
|
|
document.Category,
|
|
document.VendorStatus,
|
|
DateTime.SpecifyKind(document.RecordedAt, DateTimeKind.Utc));
|
|
}
|
|
}
|