/// <summary> /// Get total Number of Likes for a particular Post based on Id /// </summary> /// <param name="PostId"></param> /// <returns></returns> public async Task <TotalLikedPostResponse> GetAllLikesCountByPostIdAsync(string PostId) { var response = new TotalLikedPostResponse(); try { var result = await _repo.GetAllLikesCountByPostIdAsync(PostId); if (result < 1) { response.responseDescription = "This Post Has no Likes or does not Exist, Kindly double check post Id"; response.responseMessage = "Could Not Fetch Post's Likes Count"; response.responseCode = "01"; return(response); } response.TotalNumberOfLikes = result.ToString(); response.responseDescription = "Total Post Likes Fetched successfully"; } catch (Exception ex) { //Log this throw ex; } return(response); }
public async Task <IActionResult> GetLikesByPostId(string postID) { var response = new TotalLikedPostResponse(); try { _logger.LogInformation($"Fetching Likes Count for POSTID::{postID}"); var result = await _PostLikesService.GetAllLikesCountByPostIdAsync(postID); _logger.LogInformation(result.ToString()); response = result; return(Ok(response)); } catch (Exception ex) { _logger.LogError(ex.Message); } return(StatusCode(500, response)); }