예제 #1
0
        public async Task <IActionResult> SetProfilePicture(
            string battleTag,
            [FromBody] SetPictureCommand command)
        {
            var result = await _commandHandler.UpdatePicture(battleTag, command);

            if (!result)
            {
                return(BadRequest());
            }

            return(Ok());
        }
        public async Task SetPictureWhenSettingsAreNotThere()
        {
            var personalSettingsRepository = new PersonalSettingsRepository(MongoClient);
            var playerRepo             = new PlayerRepository(MongoClient);
            var portraitRepo           = new PortraitRepository(MongoClient);
            var portraitCommandHandler = new PortraitCommandHandler(personalSettingsRepository, playerRepo, portraitRepo);

            var player = PlayerOverallStats.Create("modmoto#123");

            for (int i = 0; i < 30; i++)
            {
                player.RecordWin(Race.NE, 1, true);
            }

            await playerRepo.UpsertPlayer(player);

            var result = await portraitCommandHandler.UpdatePicture("modmoto#123",
                                                                    new SetPictureCommand { avatarCategory = AvatarCategory.NE, pictureId = 2 });

            Assert.IsTrue(result);
            var settings = await personalSettingsRepository.Load("modmoto#123");

            Assert.AreEqual(2, settings.ProfilePicture.PictureId);
        }