diff --git a/FreeTubeSync/EndPoints/HistoryEndpoint.cs b/FreeTubeSync/EndPoints/HistoryEndpoint.cs index 7f6d0d0..d57c233 100644 --- a/FreeTubeSync/EndPoints/HistoryEndpoint.cs +++ b/FreeTubeSync/EndPoints/HistoryEndpoint.cs @@ -20,7 +20,10 @@ public static class HistoryEndpoint if (results == null) await repository.AddAsync(history, ct); else - await repository.UpdateAsync(history, ct); + { + results.Update(history); + await repository.UpdateAsync(results, ct); + } return Results.Ok(); }); diff --git a/FreeTubeSync/EndPoints/PlaylistEndpoint.cs b/FreeTubeSync/EndPoints/PlaylistEndpoint.cs index a7a962f..383d8da 100644 --- a/FreeTubeSync/EndPoints/PlaylistEndpoint.cs +++ b/FreeTubeSync/EndPoints/PlaylistEndpoint.cs @@ -20,7 +20,11 @@ public static class PlaylistEndpoint if (results == null) await repository.AddAsync(playlist, ct); else - await repository.UpdateAsync(playlist, ct); + { + results.Update(playlist); + await repository.UpdateAsync(results, ct); + } + return Results.Ok(); }); diff --git a/FreeTubeSync/EndPoints/ProfileEndpoint.cs b/FreeTubeSync/EndPoints/ProfileEndpoint.cs index 17b298c..80fc531 100644 --- a/FreeTubeSync/EndPoints/ProfileEndpoint.cs +++ b/FreeTubeSync/EndPoints/ProfileEndpoint.cs @@ -20,7 +20,11 @@ public static class ProfileEndpoint if (res == null) await repository.AddAsync(profile, ct); else - await repository.UpdateAsync(profile, ct); + { + res.Update(profile); + await repository.UpdateAsync(res, ct); + } + return Results.Ok(); }); diff --git a/FreeTubeSync/EndPoints/SearchHistoryEndpoint.cs b/FreeTubeSync/EndPoints/SearchHistoryEndpoint.cs index 8908ddc..5948186 100644 --- a/FreeTubeSync/EndPoints/SearchHistoryEndpoint.cs +++ b/FreeTubeSync/EndPoints/SearchHistoryEndpoint.cs @@ -17,10 +17,14 @@ public static class SearchHistoryEndpoint group.MapPost("/", async (IRepository repository, CancellationToken ct, SearchHistory history) => { var result = await repository.GetByIdAsync(history._id, ct); - if (result != null) - await repository.UpdateAsync(history, ct); - else + if (result == null) await repository.AddAsync(history, ct); + else + { + result.Update(history); + await repository.UpdateAsync(result, ct); + } + return Results.Ok(); }); diff --git a/FreeTubeSync/EndPoints/SettingEndpoint.cs b/FreeTubeSync/EndPoints/SettingEndpoint.cs index fdb9dc8..1b053f0 100644 --- a/FreeTubeSync/EndPoints/SettingEndpoint.cs +++ b/FreeTubeSync/EndPoints/SettingEndpoint.cs @@ -22,7 +22,10 @@ public static class SettingEndpoint if (res == null) await repository.AddAsync(setting, ct); else - await repository.UpdateAsync(setting, ct); + { + res.Update(setting); + await repository.UpdateAsync(res, ct); + } return Results.Ok(); }); diff --git a/FreeTubeSync/Model/Playlist.cs b/FreeTubeSync/Model/Playlist.cs index 2d1627e..6f2abb7 100644 --- a/FreeTubeSync/Model/Playlist.cs +++ b/FreeTubeSync/Model/Playlist.cs @@ -1,5 +1,6 @@ using System.ComponentModel.DataAnnotations; using System.Diagnostics.CodeAnalysis; +using Microsoft.EntityFrameworkCore.Query.Internal; namespace FreeTubeSync.Model; @@ -18,7 +19,20 @@ public class Playlist { if (other.playlistName != playlistName) playlistName = other.playlistName; if (other.@protected != @protected) @protected = other.@protected; - if (other.videos.Count != videos.Count) videos = other.videos; + var remove = new List