From eba8e9698c09b805d8ac2a8f58db93b947ac29e3 Mon Sep 17 00:00:00 2001 From: crupest Date: Sat, 13 Jun 2020 00:28:35 +0800 Subject: refactor(back): Fix #100 . --- Timeline/Services/TimelineService.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'Timeline/Services/TimelineService.cs') diff --git a/Timeline/Services/TimelineService.cs b/Timeline/Services/TimelineService.cs index aecfeeec..a473ae66 100644 --- a/Timeline/Services/TimelineService.cs +++ b/Timeline/Services/TimelineService.cs @@ -10,6 +10,7 @@ using Timeline.Entities; using Timeline.Helpers; using Timeline.Models; using Timeline.Models.Validation; +using Timeline.Services.Exceptions; using static Timeline.Resources.Services.TimelineService; namespace Timeline.Services @@ -428,7 +429,7 @@ namespace Timeline.Services var postEntity = await Database.TimelinePosts.Where(p => p.TimelineId == timelineId && p.LocalId == postId).SingleOrDefaultAsync(); if (postEntity == null) - throw new TimelinePostNotExistException(name, postId); + throw new TimelinePostNotExistException(name, postId, false); if (postEntity.Content == null) throw new TimelinePostNotExistException(name, postId, true); @@ -450,7 +451,7 @@ namespace Timeline.Services var postEntity = await Database.TimelinePosts.Where(p => p.TimelineId == timelineId && p.LocalId == postId).SingleOrDefaultAsync(); if (postEntity == null) - throw new TimelinePostNotExistException(name, postId); + throw new TimelinePostNotExistException(name, postId, false); if (postEntity.Content == null) throw new TimelinePostNotExistException(name, postId, true); @@ -586,7 +587,7 @@ namespace Timeline.Services var post = await Database.TimelinePosts.Where(p => p.TimelineId == timelineId && p.LocalId == id).SingleOrDefaultAsync(); if (post == null || post.Content == null) - throw new TimelinePostNotExistException(name, id); + throw new TimelinePostNotExistException(name, id, false); string? dataTag = null; @@ -977,7 +978,7 @@ namespace Timeline.Services var conflict = await _database.Timelines.AnyAsync(t => t.Name == name); if (conflict) - throw new ConflictException(ExceptionTimelineNameConflict); + throw new EntityAlreadyExistException(EntityNames.Timeline, null, ExceptionTimelineNameConflict); var newEntity = new TimelineEntity { -- cgit v1.2.3