aboutsummaryrefslogtreecommitdiff
path: root/BackEnd
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-01-03 19:38:05 +0800
committerGitHub <noreply@github.com>2021-01-03 19:38:05 +0800
commitd6f5cc98880b4664baf223d7147feb466e3cce5d (patch)
treeccc1167e69d7e8fcc58760e2d7de3a534150cff3 /BackEnd
parentd25b74fa167944a7701997e34810a2ffc3c39edd (diff)
parent1b7a9096b1fd7c26a9336950a4a4b4253bcb5926 (diff)
downloadtimeline-d6f5cc98880b4664baf223d7147feb466e3cce5d.tar.gz
timeline-d6f5cc98880b4664baf223d7147feb466e3cce5d.tar.bz2
timeline-d6f5cc98880b4664baf223d7147feb466e3cce5d.zip
Merge pull request #197 from crupest/front-dev
Front: Highlight and bookmark timeline and new home page.
Diffstat (limited to 'BackEnd')
-rw-r--r--BackEnd/Timeline.Tests/Services/BookmarkTimelineServiceTest.cs13
-rw-r--r--BackEnd/Timeline/Services/BookmarkTimelineService.cs5
2 files changed, 18 insertions, 0 deletions
diff --git a/BackEnd/Timeline.Tests/Services/BookmarkTimelineServiceTest.cs b/BackEnd/Timeline.Tests/Services/BookmarkTimelineServiceTest.cs
index 1b8bff63..849936ec 100644
--- a/BackEnd/Timeline.Tests/Services/BookmarkTimelineServiceTest.cs
+++ b/BackEnd/Timeline.Tests/Services/BookmarkTimelineServiceTest.cs
@@ -85,5 +85,18 @@ namespace Timeline.Tests.Services
await _service.RemoveBookmark(userId, "t3");
(await _service.GetBookmarks(userId)).Should().BeEmpty();
}
+
+ [Fact]
+ public async Task AddExist_Should_DoNothing()
+ {
+ var userId = await _userService.GetUserIdByUsername("user");
+
+ await _timelineService.CreateTimeline("t", userId);
+
+ await _service.AddBookmark(userId, "t");
+ await _service.AddBookmark(userId, "t");
+
+ (await _service.GetBookmarks(userId)).Should().HaveCount(1);
+ }
}
}
diff --git a/BackEnd/Timeline/Services/BookmarkTimelineService.cs b/BackEnd/Timeline/Services/BookmarkTimelineService.cs
index 09438193..2ec3af62 100644
--- a/BackEnd/Timeline/Services/BookmarkTimelineService.cs
+++ b/BackEnd/Timeline/Services/BookmarkTimelineService.cs
@@ -94,6 +94,11 @@ namespace Timeline.Services
var timelineId = await _timelineService.GetTimelineIdByName(timelineName);
+ if (await _database.BookmarkTimelines.SingleOrDefaultAsync(t => t.TimelineId == timelineId) is not null)
+ {
+ return;
+ }
+
_database.BookmarkTimelines.Add(new BookmarkTimelineEntity
{
TimelineId = timelineId,