예제 #1
0
        public async Task <IActionResult> FollowPlayer(PlayerFollowDto playerFollowDto)
        {
            try
            {
                var user = await _userManager.GetUserAsync(User);

                if (user.PlayerFollows.FirstOrDefault(f => f.PlayerTag == playerFollowDto.Id) != null)
                {
                    return(BadRequest());
                }

                await _followService.AddPlayerFollowAsync(new PlayerFollow
                {
                    PlayerTag  = playerFollowDto.Id,
                    PlayerName = playerFollowDto.PlayerName,
                    Follower   = user,
                }, user.Id);

                await _followService.SaveAllAsync();
            }
            catch (Exception e)
            {
                return(BadRequest(e));
            }

            return(Ok());
        }