docs: #277 api for adding private notes to bookmarks
This commit is contained in:
parent
745de6a8d6
commit
36fe12e789
@ -2222,6 +2222,28 @@ namespace RMuseum.Controllers
|
||||
return Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// modify bookmark private note
|
||||
/// </summary>
|
||||
/// <param name="bookmarkId"></param>
|
||||
/// <param name="note"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
[Route("bookmark/{bookmarkId}")]
|
||||
[Authorize]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK)]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public async Task<IActionResult> ModifyBookmarkPrivateNoteAsync(Guid bookmarkId, [FromBody] string note)
|
||||
{
|
||||
if (ReadOnlyMode)
|
||||
return BadRequest("سایت به دلایل فنی مثل انتقال سرور موقتاً در حالت فقط خواندنی قرار دارد. لطفاً ساعاتی دیگر مجدداً تلاش کنید.");
|
||||
Guid loggedOnUserId = new Guid(User.Claims.FirstOrDefault(c => c.Type == "UserId").Value);
|
||||
RServiceResult<bool> res = await _ganjoorService.ModifyBookmarkPrivateNoteAsync(bookmarkId, loggedOnUserId, note);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// get poem user bookmarks (only Id, CoupletIndex and DateTime are valid in the output view model)
|
||||
|
||||
@ -1384,6 +1384,14 @@
|
||||
<param name="bookmarkId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.ModifyBookmarkPrivateNoteAsync(System.Guid,System.String)">
|
||||
<summary>
|
||||
modify bookmark private note
|
||||
</summary>
|
||||
<param name="bookmarkId"></param>
|
||||
<param name="note"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.GetPoemUserBookmarks(System.Int32)">
|
||||
<summary>
|
||||
get poem user bookmarks (only Id, CoupletIndex and DateTime are valid in the output view model)
|
||||
@ -10316,6 +10324,15 @@
|
||||
<param name="userId">to make sure a user can not delete another user's bookmarks</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.ModifyBookmarkPrivateNoteAsync(System.Guid,System.Guid,System.String)">
|
||||
<summary>
|
||||
modify bookmark private note
|
||||
</summary>
|
||||
<param name="bookmarkId"></param>
|
||||
<param name="userId">to make sure a user can not modify another user's bookmarks</param>
|
||||
<param name="note"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.GetPoemUserBookmarks(System.Guid,System.Int32)">
|
||||
<summary>
|
||||
get user ganjoor bookmarks (only Id, CoupletIndex and DateTime are valid)
|
||||
@ -11666,6 +11683,15 @@
|
||||
<param name="userId">to make sure a user can not delete another user's bookmarks</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.ModifyBookmarkPrivateNoteAsync(System.Guid,System.Guid,System.String)">
|
||||
<summary>
|
||||
modify bookmark private note
|
||||
</summary>
|
||||
<param name="bookmarkId"></param>
|
||||
<param name="userId">to make sure a user can not modify another user's bookmarks</param>
|
||||
<param name="note"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetUserBookmarks(RSecurityBackend.Models.Generic.PagingParameterModel,System.Guid)">
|
||||
<summary>
|
||||
get user bookmarks (artifacts and items)
|
||||
|
||||
@ -659,6 +659,15 @@ namespace RMuseum.Services
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<bool>> DeleteGanjoorBookmark(Guid bookmarkId, Guid userId);
|
||||
|
||||
/// <summary>
|
||||
/// modify bookmark private note
|
||||
/// </summary>
|
||||
/// <param name="bookmarkId"></param>
|
||||
/// <param name="userId">to make sure a user can not modify another user's bookmarks</param>
|
||||
/// <param name="note"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<bool>> ModifyBookmarkPrivateNoteAsync(Guid bookmarkId, Guid userId, string note);
|
||||
|
||||
/// <summary>
|
||||
/// get user ganjoor bookmarks (only Id, CoupletIndex and DateTime are valid)
|
||||
/// </summary>
|
||||
|
||||
@ -149,6 +149,34 @@ namespace RMuseum.Services.Implementation
|
||||
return new RServiceResult<bool>(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// modify bookmark private note
|
||||
/// </summary>
|
||||
/// <param name="bookmarkId"></param>
|
||||
/// <param name="userId">to make sure a user can not modify another user's bookmarks</param>
|
||||
/// <param name="note"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<bool>> ModifyBookmarkPrivateNoteAsync(Guid bookmarkId, Guid userId, string note)
|
||||
{
|
||||
try
|
||||
{
|
||||
GanjoorUserBookmark bookmark = await _context.GanjoorUserBookmarks.Where(b => b.Id == bookmarkId && b.UserId == userId).SingleOrDefaultAsync();
|
||||
if (bookmark == null)
|
||||
{
|
||||
return new RServiceResult<bool>(false, "bookmark not found");
|
||||
}
|
||||
bookmark.PrivateNote = note;
|
||||
_context.Update(bookmark);
|
||||
await _context.SaveChangesAsync();
|
||||
return new RServiceResult<bool>(true);
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
return new RServiceResult<bool>(false, exp.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get user bookmarks (artifacts and items)
|
||||
/// </summary>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user