Example #1
0
        public string HandleNewSession(ISession session, IPlayer player)
        {
            var currentPlayer = _playerService.Add(player);

            _sessionService.UpdateCurrentPlayer(session.Id, currentPlayer);

            _sessionService.UpdateStatus(session.Id, SessionStatus.AddingPlayer);

            return($"Добро пожаловать в игру, {player.Name}! Хотите добавить еще одного игрока?");
        }
Example #2
0
        // change to decorator pattern !
        private void CreatePlayer(int teamId, int position, int gameDetailsId)
        {
            // create basic player info
            var player = new Player
            {
                TeamId        = teamId,
                Age           = Utilities.Utilities.GetRandomNumber(18, 38),
                Position      = position,
                Name          = Utilities.Utilities.GetRandomName(),
                GameDetailsId = gameDetailsId
            };
            var playerId = _playerService.Add(player);

            player.Id = playerId;

            // create attributes
            var attributeList = CreateNewPlayerAttributes(player);

            foreach (var attr in attributeList)
            {
                _playerAttributeService.Add(attr);
            }

            // create stats
            _playerStatsService.Add(new PlayerStats {
                PlayerId = playerId
            });

            _playerService.RecalculateRatingAndValue(playerId);
        }
Example #3
0
        public IActionResult Create(CreatePlayerViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Error", "Home"));
            }

            if (!_playerServices.CheckNameIsAvailable(model.PlayerName))
            {
                return(this.View());
            }

            var userid = this._userManager.GetUserId(this.User);

            //ADD Default configuration
            var player = this.mapper.Map <Player>(model);

            player.AplicationUserId = userid;
            player.NodeId           = "1001";
            player.Money            = 1000;
            player.PlanPlayers.Add(new PlanPlayer()
            {
                PlanId = 1
            });
            player.PlayerShips.Add(new PlayerShip()
            {
                ShipId = 1
            });

            _playerServices.Add(player);

            return(this.View("Index", player));
        }
Example #4
0
        public async Task <IActionResult> Save(PlayerViewModel model)
        {
            PlayerDTO playerToAdd  = Mapping.Mapper.Map <PlayerDTO>(model);
            Status    addingStatus = await _playerService.Add(playerToAdd);

            return(RedirectToAction("Details", "TeamMenagment", new { id = playerToAdd.TeamId }));
        }
Example #5
0
        public HttpResponseMessage AddPlayer(string username)
        {
            _playerService.Add(username);

            var response = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.Created,
            };

            return(response);
        }
Example #6
0
        public void Add(PlayerDTO obj)
        {
            try
            {
                TeamCompletedException(obj);

                _playerService.Add(_playerMapper.MapperToEntity(obj));
            }
            catch (System.Exception)
            {
                throw;
            }
        }
Example #7
0
        public async void TestCRUDSingle(Player newPlayer, JsonElement updateToken)
        {
            // Add single
            CUDMessage addMessage = await playerService.Add(newPlayer);

            Assert.True(addMessage.OK);
            IPlayer playerInDB = await playerService.Get(newPlayer.DBName);

            Assert.NotNull(playerInDB);
            // update single
            CUDMessage updateMessage = await playerService.Update(newPlayer.DBName, updateToken);

            playerInDB = await playerService.Get(newPlayer.DBName);

            Assert.Equal("game-tesV", playerInDB.Games[0]);
            // delete single
            CUDMessage deleteMessage = await playerService.Delete(newPlayer.DBName);

            Assert.True(deleteMessage.OK);
            playerInDB = await playerService.Get(newPlayer.DBName);

            Assert.Null(playerInDB);
        }
        public async Task <ActionResult> Create(PlayerViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var result = await _playerService.Add(viewModel.ToModel());

                if (result)
                {
                    ViewBag.Message = "Player Added Successfully";
                    ModelState.Clear();
                }
            }

            return(View(viewModel));
        }
Example #9
0
        public ValidationResult Add(PlayerViewModel model)
        {
            var player = Mapper.Map <PlayerViewModel, Player>(model);

            if (!player.IsValid())
            {
                return(player.ValidationResult);
            }

            ValidateHeroes(ref player);

            if (!player.ValidationResult.IsValid)
            {
                return(player.ValidationResult);
            }

            player.ValidationResult.Add(_playerService.Add(player));

            return(player.ValidationResult);
        }
Example #10
0
 public IActionResult Add([FromBody] Player player)
 {
     PlayerService.Add(player);
     PlayerService.SaveChanges();
     return(Created("Player created", player.Name));
 }
Example #11
0
 public void Add(string connId)
 {
     _playerService.Add(new Player(connId));
 }
Example #12
0
 public void Add(string playerName)
 {
     _playerService.Add(playerName);
 }
Example #13
0
 public void Register(Person person)
 {
     _playerService.CheckPerson(person);
     _playerService.Add(person);
 }
Example #14
0
        public async Task <IActionResult> Add([FromBody] PlayerDTO playerDTO)
        {
            await _playerService.Add(_mapper.Map <Player>(playerDTO));

            return(new OkObjectResult(true));
        }
Example #15
0
 public void Post([FromBody] Player player)
 {
     _playerService.Add(player);
 }
 public IHttpActionResult AddPlayer(PlayerViewModel player)
 {
     player = Mapper.Map <PlayerViewModel>(_playerService.Add(Mapper.Map <DTOPlayer>(player)));
     return(Ok(player));
 }
 public async Task <IActionResult> AddPlayer(Player model) => Ok(await _playerService.Add(model));