BusinessLogic.Logic.Players.PlayerSaver.CreatePlayer C# (CSharp) Метод

CreatePlayer() публичный Метод

public CreatePlayer ( CreatePlayerRequest createPlayerRequest, ApplicationUser applicationUser, bool linkCurrentUserToThisPlayer = false ) : Player
createPlayerRequest BusinessLogic.Models.Players.CreatePlayerRequest
applicationUser ApplicationUser
linkCurrentUserToThisPlayer bool
Результат Player
        public Player CreatePlayer(CreatePlayerRequest createPlayerRequest, ApplicationUser applicationUser, bool linkCurrentUserToThisPlayer = false)
        {
            if (createPlayerRequest == null)
            {
                throw new ArgumentNullException(nameof(createPlayerRequest));
            }
            ValidatePlayerNameIsNotNullOrWhiteSpace(createPlayerRequest.Name);
            int gamingGroupId = createPlayerRequest.GamingGroupId ?? applicationUser.CurrentGamingGroupId;
            ThrowPlayerAlreadyExistsExceptionIfPlayerExistsWithThisName(createPlayerRequest.Name, gamingGroupId);

            var newPlayer = new Player
            {
                Name = createPlayerRequest.Name,
                Active = true,
                ApplicationUserId = linkCurrentUserToThisPlayer ? applicationUser.Id : null,
                GamingGroupId = gamingGroupId
            };

            newPlayer = _dataContext.Save(newPlayer, applicationUser);
            _dataContext.CommitAllChanges();

            new Task(() => _eventTracker.TrackPlayerCreation(applicationUser)).Start();

            return newPlayer;
        }