aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Services/TimelineService.cs
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
commit23b3f79f4d1b48eb4a230402b1ad88a8d5409d24 (patch)
tree78c2cf292c0bca4c77f8af458ef0c9586c01077c /Timeline/Services/TimelineService.cs
parent14f9493d41738a8b3523ed498838ad1f373b9377 (diff)
downloadtimeline-23b3f79f4d1b48eb4a230402b1ad88a8d5409d24.tar.gz
timeline-23b3f79f4d1b48eb4a230402b1ad88a8d5409d24.tar.bz2
timeline-23b3f79f4d1b48eb4a230402b1ad88a8d5409d24.zip
Change post content to null instead of delete the entity when deleting post.
Diffstat (limited to 'Timeline/Services/TimelineService.cs')
-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();
}