public async Task <TextPostLike> Like(TextPostLike textPostLike) { await _textPostLikes.AddAsync(textPostLike); await _context.SaveChangesAsync(); return(textPostLike); }
public async Task <IActionResult> LikeTextPost([FromBody] TextPost textPost) { var applicationUser = await _userManager.GetUserAsync(HttpContext.User); if (applicationUser == null) { return(Unauthorized()); } var user = _userService.GetUserById(applicationUser.Id); var textPostLike = new TextPostLike { LikeOwner = user }; textPost.Likes.Add(textPostLike); await _service.Like(textPostLike); var likedTextPost = await _service.Update(textPost); return(Ok(likedTextPost)); }
public async Task <TextPostLike> Like(TextPostLike textPostLike) { var result = await _repository.Like(textPostLike); return(result); }