diff options
Diffstat (limited to 'Backend/Api')
-rw-r--r-- | Backend/Api/Api/Models/Post.cs | 4 | ||||
-rw-r--r-- | Backend/Api/Api/Services/PostService.cs | 11 |
2 files changed, 8 insertions, 7 deletions
diff --git a/Backend/Api/Api/Models/Post.cs b/Backend/Api/Api/Models/Post.cs index dbe7952..22ed62e 100644 --- a/Backend/Api/Api/Models/Post.cs +++ b/Backend/Api/Api/Models/Post.cs @@ -19,7 +19,7 @@ namespace Api.Models public List<Comment> comments { get; set; } public List<File> images { get; set; } public List<string>? tags { get; set; } - public List<string>? favorites { get; set; } + public List<string>? favourites { get; set; } } public class PostReceive @@ -44,7 +44,7 @@ namespace Api.Models public List<File> images { get; set; } public List<string>? tags { get; set; } public DateTime? lastViewed { get; set; } - public List<string>? favorites { get; set; } + public List<string>? favourites { get; set; } } public class Rating { diff --git a/Backend/Api/Api/Services/PostService.cs b/Backend/Api/Api/Services/PostService.cs index 17c96e3..fd42d08 100644 --- a/Backend/Api/Api/Services/PostService.cs +++ b/Backend/Api/Api/Services/PostService.cs @@ -89,6 +89,7 @@ namespace Api.Services p.createdAt = post.createdAt; p.tags = post.tags; p.ratingscount = post.ratings.Count(); + p.favourites = post.favourites; if (post.ratings.Count() > 0) { List<int> ratings = new List<int>(); @@ -537,16 +538,16 @@ namespace Api.Services Post post = await _posts.Find(x => x._id == postId).FirstOrDefaultAsync(); if (userId == null || post==null) return result; - if (post.favorites == null) - post.favorites = new List<string>(); - if (post.favorites.Contains(userId)) + if (post.favourites == null) + post.favourites = new List<string>(); + if (post.favourites.Contains(userId)) { - post.favorites.Remove(userId); + post.favourites.Remove(userId); result = false; } else { - post.favorites.Add(userId); + post.favourites.Add(userId); result = true; } |