aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Services
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2019-11-20 16:40:41 +0800
committercrupest <crupest@outlook.com>2019-11-20 16:40:41 +0800
commitac3a053868787f682ccf6b31a0023082fd8c9f37 (patch)
tree78c2cf292c0bca4c77f8af458ef0c9586c01077c /Timeline/Services
parenteb35c608b3d73db2cd819a8280fa1cdce1f59dc2 (diff)
downloadtimeline-ac3a053868787f682ccf6b31a0023082fd8c9f37.tar.gz
timeline-ac3a053868787f682ccf6b31a0023082fd8c9f37.tar.bz2
timeline-ac3a053868787f682ccf6b31a0023082fd8c9f37.zip
Change post content to null instead of delete the entity when deleting post.
Diffstat (limited to 'Timeline/Services')
-rw-r--r--Timeline/Services/TimelineService.cs6
1 files changed, 4 insertions, 2 deletions
diff --git a/Timeline/Services/TimelineService.cs b/Timeline/Services/TimelineService.cs
index a2ff4098..9ae9dc1c 100644
--- a/Timeline/Services/TimelineService.cs
+++ b/Timeline/Services/TimelineService.cs
@@ -348,7 +348,7 @@ namespace Timeline.Services
throw new ArgumentNullException(nameof(name));
var timelineId = await FindTimelineId(name);
- var postEntities = await Database.TimelinePosts.Where(p => p.TimelineId == timelineId).ToListAsync();
+ var postEntities = await Database.TimelinePosts.Where(p => p.TimelineId == timelineId && p.Content != null).ToListAsync();
var posts = new List<TimelinePostInfo>(await Task.WhenAll(postEntities.Select(async p => new TimelinePostInfo
{
Id = p.Id,
@@ -418,7 +418,9 @@ namespace Timeline.Services
if (post == null)
throw new TimelinePostNotExistException(id);
- Database.TimelinePosts.Remove(post);
+ post.Content = null;
+ post.LastUpdated = Clock.GetCurrentTime();
+
await Database.SaveChangesAsync();
}