public async Task <ActionResult> AddDislike(string username) { var sourceUserId = User.GetUserId(); var dislikedUser = await _userRepository.GetUserByUsernameAsync(username); var sourceUser = await _likesRepository.GetUserWithDislikes(sourceUserId); if (dislikedUser == null) { return(NotFound()); } if (sourceUser.UserName == username) { return(BadRequest("You can not dislike youself")); } var userDislike = await _likesRepository.GetUserDislike(sourceUserId, dislikedUser.Id); if (userDislike != null) { return(BadRequest("You already disliked this user")); } userDislike = new Entities.UserDisLike { SourceUserId = sourceUserId, DisLikedUserId = dislikedUser.Id }; sourceUser.DisLikedUsers.Add(userDislike); if (await _userRepository.SaveAllAsync()) { return(Ok()); } return(BadRequest("failed to dislike user")); }