Exemple #1
0
 public PlayerHuman(PlayerCreateDTO playerCreateDTO, int playerId)
 {
     this.Id           = playerId;
     this.Name         = playerCreateDTO.Name;
     this.PlayerColour = playerCreateDTO.PlayerColour;
     this.PlayerType   = PlayerType.Human;
 }
        public void Create(PlayerCreateDTO item)
        {
            var player = new Player(item.Nome, item.TimeId);

            _context.Add(player);
            _context.SaveChanges();
        }
        public async Task <PlayerDTO> Create([FromBody] PlayerCreateDTO value)
        {
            var player = _mapper.Map <Player>(value);

            player = await _service.Create(player, value.Password).ConfigureAwait(false);

            return(_mapper.Map <PlayerDTO>(player));
        }
Exemple #4
0
        public async Task CreatePlayer(PlayerCreateDTO player)
        {
            var httpResponse = await httpService.Post($"{url}", player);

            if (!httpResponse.Success)
            {
                throw new ApplicationException(await httpResponse.GetBody());
            }
        }
        public async Task <IActionResult> Create([FromBody] PlayerCreateDTO model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorsMessage()));
            }

            var mappedEntity = Mapper.Map <Player>(model);

            await UnitOfWork.PlayerRepository.AddAsync(mappedEntity);

            await UnitOfWork.CommitAsync();

            return(Ok(new IdentifierResponse()
            {
                Id = mappedEntity.Id
            }));
        }