public IHttpActionResult AssignAchievement(string achievementName)
        {
            var username = User.Identity.Name;

            _service.AssignAchievementToUser(username, achievementName);
            return(Ok());
        }
Пример #2
0
        public async Task <IHttpActionResult> Register(PlayerRegisterDto newPlayer)
        {
            if (newPlayer == null || !ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (!service.CheckUsernameAvailability(newPlayer.UserName))
            {
                return(BadRequest("This username has been already taken. Try another one."));
            }
            var player = mapper.Map <Player>(newPlayer);

            var result = await service.AddPlayer(player, newPlayer.UserName, newPlayer.Password, newPlayer.Email);

            _achievementsService.AssignAchievementToUser(newPlayer.UserName, "AccountCreated");
            return(!result.Succeeded ? GetErrorResult(result) : Ok());
        }