|
@@ -94,8 +94,9 @@ namespace GxPress.Service.Implement.Note
|
|
|
/// </summary>
|
|
|
/// <param name="request"></param>
|
|
|
/// <returns></returns>
|
|
|
- public async Task<bool> InsertNoteAsync(NoteInRequest request)
|
|
|
+ public async Task<NoteAddOrModifyResult> InsertNoteAsync(NoteInRequest request)
|
|
|
{
|
|
|
+ var result = new NoteAddOrModifyResult();
|
|
|
try
|
|
|
{
|
|
|
using (TransactionScope transactionScope = new TransactionScope())
|
|
@@ -123,8 +124,11 @@ namespace GxPress.Service.Implement.Note
|
|
|
CatalogId = request.CatalogId,
|
|
|
ChapterId = request.ChapterId,
|
|
|
//是否草稿
|
|
|
- IsDraft = request.IsDraft
|
|
|
+ IsDraft = request.IsDraft,
|
|
|
+ Id = request.Id
|
|
|
};
|
|
|
+ if (note.Id > 0)
|
|
|
+ return await UpdateNoteAsync(note);
|
|
|
var noteId = await _noteRepository.InsertAsync(note);
|
|
|
if (!request.IsDraft)
|
|
|
{
|
|
@@ -145,6 +149,10 @@ namespace GxPress.Service.Implement.Note
|
|
|
}
|
|
|
//添加默认文件夹
|
|
|
await recordFolderRepository.AddAsync(request.IsTopic ? AllTypeConst.TopicNote.GetHashCode() : AllTypeConst.Note.GetHashCode(), request.UserId, request.FolderId);
|
|
|
+ var middle = await _middleRepository.GetMiddleAsync(request.FolderId);
|
|
|
+ result.Id = noteId;
|
|
|
+ result.FolderId = request.FolderId;
|
|
|
+ result.FolderName = middle.FolderName;
|
|
|
transactionScope.Complete();
|
|
|
}
|
|
|
}
|
|
@@ -153,7 +161,7 @@ namespace GxPress.Service.Implement.Note
|
|
|
Console.WriteLine(e);
|
|
|
throw;
|
|
|
}
|
|
|
- return true;
|
|
|
+ return result;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取笔记/话题草稿分页
|
|
@@ -581,7 +589,7 @@ namespace GxPress.Service.Implement.Note
|
|
|
/// </summary>
|
|
|
/// <param name="note"></param>
|
|
|
/// <returns></returns>
|
|
|
- public async Task<bool> UpdateNoteAsync(Entity.Note.Note note)
|
|
|
+ public async Task<NoteAddOrModifyResult> UpdateNoteAsync(Entity.Note.Note note)
|
|
|
{
|
|
|
var entity = await _noteRepository.GetAsync(note.Id);
|
|
|
if (string.IsNullOrWhiteSpace(note.Content) && string.IsNullOrWhiteSpace(note.Title))
|
|
@@ -634,7 +642,15 @@ namespace GxPress.Service.Implement.Note
|
|
|
await recordFolderRepository.AddAsync(note.IsTopic ? AllTypeConst.TopicNote.GetHashCode() : AllTypeConst.Note.GetHashCode(), note.UserId, note.FolderId);
|
|
|
entity.Title = note.Title;
|
|
|
entity.IsDraft = note.IsDraft;
|
|
|
- return await _noteRepository.UpdateAsync(entity);
|
|
|
+ await _noteRepository.UpdateAsync(entity);
|
|
|
+ var middleDto = await _middleRepository.GetMiddleAsync(entity.FolderId);
|
|
|
+ var result = new NoteAddOrModifyResult()
|
|
|
+ {
|
|
|
+ Id = entity.Id,
|
|
|
+ FolderId = entity.FolderId,
|
|
|
+ FolderName = middleDto.FolderName
|
|
|
+ };
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
public async Task<bool> DeleteAsync(int id, int userId)
|