diff --git a/RMuseum/Controllers/GanjoorController.cs b/RMuseum/Controllers/GanjoorController.cs index c33bac02..c3995659 100644 --- a/RMuseum/Controllers/GanjoorController.cs +++ b/RMuseum/Controllers/GanjoorController.cs @@ -515,6 +515,42 @@ namespace RMuseum.Controllers return Ok(comments.Result.Items); } + /// + /// get logged on users recent comments + /// + /// + /// + + [HttpGet] + [Route("comments/mine")] + [Authorize] + [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(IEnumerable))] + [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] + + public async Task GetMyRecentComments([FromQuery] PagingParameterModel paging) + { + Guid userId = + new Guid(User.Claims.FirstOrDefault(c => c.Type == "UserId").Value); + Guid sessionId = + new Guid(User.Claims.FirstOrDefault(c => c.Type == "SessionId").Value); + RServiceResult sessionCheckResult = await _appUserService.SessionExists(userId, sessionId); + if (!string.IsNullOrEmpty(sessionCheckResult.ExceptionString)) + { + return StatusCode((int)HttpStatusCode.Forbidden); + } + + var comments = await _ganjoorService.GetRecentComments(paging, userId, false); + if (!string.IsNullOrEmpty(comments.ExceptionString)) + { + return BadRequest(comments.ExceptionString); + } + + // Paging Header + HttpContext.Response.Headers.Add("paging-headers", JsonConvert.SerializeObject(comments.Result.PagingMeta)); + + return Ok(comments.Result.Items); + } + /// diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml index efe3f5cc..22538f3f 100644 --- a/RMuseum/RMuseum.xml +++ b/RMuseum/RMuseum.xml @@ -772,6 +772,13 @@ + + + get logged on users recent comments + + + + post new comment