public CreatedPlayerDTO Create(Guid teamId, string name)
        {
            var player           = new Player(teamId, name);
            var playerValidation = player.Validate();

            if (playerValidation.isValid)
            {
                _playersRepository.Add(player);
                return(new CreatedPlayerDTO(player.Id));
            }

            return(new CreatedPlayerDTO(playerValidation.errors));
        }
Example #2
0
        public CreatedPlayerDto Create(string name)
        {
            var player         = new Player(name);
            var validatePlayer = player.Validate();

            if (validatePlayer.isValid)
            {
                PlayersRepository.Add(player);
                return(new CreatedPlayerDto(player.Id));
            }

            return(new CreatedPlayerDto(validatePlayer.errors));
        }
Example #3
0
        public CreatedPlayerDTO Update(Guid id, string name)
        {
            var player           = new Player(name);
            var playerValidation = player.Validate();

            if (playerValidation.isValid)
            {
                PlayersRepository.Remove(id);
                PlayersRepository.Add(player);
                return(new CreatedPlayerDTO(player.Id));
            }

            return(new CreatedPlayerDTO(playerValidation.errors));
        }