public IActionResult Update([FromBody] UpdateChapterDto chapterDto) { UpdateChapterResponseDto responseDto = null; try { if (_httpContextAccessor.GetCurrentUserId() != chapterDto.AuthorId) { throw new UnauthorizedAccessException("You are not authorized to update the specified chapter."); } var chapterEntity = _chapterService.UpdateChapter( chapterDto.ChapterId, chapterDto.AuthorId, chapterDto.BookId, chapterDto.TimelineId, chapterDto.SortOrder, chapterDto.Title, chapterDto.Body); responseDto = _mapper.Map <UpdateChapterResponseDto>(chapterEntity); responseDto.Timeline = chapterEntity.Timeline == null ? null : _mapper.Map <ReadTimelineResponseDto>(chapterEntity.Timeline); } catch (Exception ex) { Console.WriteLine($"Encountered exception while attempting to update chapter. Message: {ex.Message}"); Console.WriteLine(ex.StackTrace); return(BadRequest(new ErrorResponseDto(ex))); } return(Ok(responseDto)); }
public IHttpActionResult UpdateChapter(Chapter chapter) { return(Ok(new { results = chapterService.UpdateChapter(chapter) })); }
public string UpdateChapter(Guid userId, [FromBody] ChapterDTO chapter) { return(chapterService.UpdateChapter(userId, chapter) ? "Success" : "Fail"); }
public IActionResult Put(int id, [FromBody] Chapter value) { service.UpdateChapter(id, value); return(Ok(value)); }
/// <summary> /// 更新章节 /// </summary> /// <param name="editChapterInput"></param> /// <returns></returns> public async Task <ChapterOutput> UpdateEditChapter(EditChapterInput editChapterInput) { var editChapter = await _chapterService.UpdateChapter(editChapterInput.Adapt <ChapterDto>()); return(editChapter.Adapt <ChapterOutput>()); }