public async Task AddAsync(LikePostDto likePostDto) { var itemForCheckIsExcist = await _mongoRepository .FilterByAsync(l => l.UserId == likePostDto.UserId && l.LikedEntityId == likePostDto.LikedEntityId); if (itemForCheckIsExcist != null) { throw new ArgumentException("User has already liked this entity"); } await _mongoRepository.InsertOneAsync(_mapper.Map <LikePostDto, Like>(likePostDto)); }
public JsonResult DislikePost(string postId) { var post = new LikePostDto() { PostId = postId, UserId = HttpContext.User.Identity.Name, IsLike = false }; var result = _postService.LikePost(post); return(Json(new { success = true, count = result.LikeCount })); }
public PostDto LikePost(LikePostDto likePostDto) { var request = new RestSharp.RestRequest(PostAPI.Like) { JsonSerializer = new NewtonsoftJsonSerializer() }; request.AddJsonBody(likePostDto); IRestResponse response = _client.Post(request); var json = JsonConvert.DeserializeObject <GenericAPIResponse>(response.Content); if (json.success) { var postDto = JsonConvert.DeserializeObject <PostDto>(json.result.ToString()); return(postDto); } else { return(null); } }
public PostDto UnlikePost(LikePostDto likePostDto) { throw new NotImplementedException(); }
public async Task <IActionResult> Add(LikePostDto likePostDto) { await _likeService.AddAsync(likePostDto); return(Created("Add", likePostDto)); }