From 97e6ac51ac4df58cd1229e7974d2b846b192558a Mon Sep 17 00:00:00 2001 From: crupest Date: Thu, 7 Jan 2021 20:12:00 +0800 Subject: refactor: Make mapper a service. Fix #202. --- BackEnd/Timeline/Services/TimelinePostService.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'BackEnd/Timeline/Services/TimelinePostService.cs') diff --git a/BackEnd/Timeline/Services/TimelinePostService.cs b/BackEnd/Timeline/Services/TimelinePostService.cs index 9f0fd550..a8bdbf92 100644 --- a/BackEnd/Timeline/Services/TimelinePostService.cs +++ b/BackEnd/Timeline/Services/TimelinePostService.cs @@ -3,7 +3,6 @@ using Microsoft.Extensions.Logging; using SixLabors.ImageSharp; using System; using System.Collections.Generic; -using System.Globalization; using System.Linq; using System.Threading.Tasks; using Timeline.Entities; @@ -166,12 +165,12 @@ namespace Timeline.Services if (modifiedSince.HasValue) { - query = query.Include(p => p.Author).Where(p => p.LastUpdated >= modifiedSince || (p.Author != null && p.Author.UsernameChangeTime >= modifiedSince)); + query = query.Where(p => p.LastUpdated >= modifiedSince || (p.Author != null && p.Author.UsernameChangeTime >= modifiedSince)); } query = query.OrderBy(p => p.Time); - return await query.Include(p => p.Author!.Permissions).ToListAsync(); + return await query.ToListAsync(); } public async Task GetPostDataETag(long timelineId, long postId) @@ -270,8 +269,6 @@ namespace Timeline.Services _database.TimelinePosts.Add(postEntity); await _database.SaveChangesAsync(); - await _database.Entry(postEntity).Reference(p => p.Author).Query().Include(a => a.Permissions).LoadAsync(); - return postEntity; } @@ -313,8 +310,6 @@ namespace Timeline.Services _database.TimelinePosts.Add(postEntity); await _database.SaveChangesAsync(); - await _database.Entry(postEntity).Reference(p => p.Author).Query().Include(a => a.Permissions).LoadAsync(); - return postEntity; } -- cgit v1.2.3