Updated History

Updated History to implement MarshalData() and JsonData() functions.
This commit is contained in:
Mario Steele 2025-07-24 04:25:59 -05:00
parent 102a1d5d62
commit 679449e4ec

View file

@ -1,4 +1,6 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json;
using FreeTubeSyncer.Library;
namespace FreeTubeSyncer.Models.DatabaseModels;
@ -23,4 +25,31 @@ public class History : IDataModel
public string Id() => _id;
public bool EqualId(string oid) => _id == oid;
public void MarshalData(string id, string data)
{
var tobject = JsonSerializer.Deserialize<History>(data, GlobalJsonOptions.Options);
if (tobject == null)
return;
this._id = id;
this.videoId = tobject.videoId;
this.title = tobject.title;
this.author = tobject.author;
this.authorId = tobject.authorId;
this.published = tobject.published;
this.description = tobject.description;
this.viewCount = tobject.viewCount;
this.lengthSeconds = tobject.lengthSeconds;
this.watchProgress = tobject.watchProgress;
this.timeWatched = tobject.timeWatched;
this.isLive = tobject.isLive;
this.type = tobject.type;
this.lastViewedPlaylistType = tobject.lastViewedPlaylistType;
this.lastViewedPlaylistItemId = tobject.lastViewedPlaylistItemId;
}
public string JsonData()
{
return JsonSerializer.Serialize(this);
}
}