BusinessLogic.Logic.GamingGroups.GamingGroupSaver.CreateNewGamingGroup C# (CSharp) Method

CreateNewGamingGroup() public method

public CreateNewGamingGroup ( string gamingGroupName, TransactionSource registrationSource, ApplicationUser currentUser ) : NewlyCreatedGamingGroupResult
gamingGroupName string
registrationSource TransactionSource
currentUser ApplicationUser
return BusinessLogic.Models.GamingGroups.NewlyCreatedGamingGroupResult
        public virtual NewlyCreatedGamingGroupResult CreateNewGamingGroup(
            string gamingGroupName,
            TransactionSource registrationSource,
            ApplicationUser currentUser)
        {
            ValidateGamingGroupName(gamingGroupName);

            var gamingGroup = new GamingGroup()
            {
                OwningUserId = currentUser.Id,
                Name = gamingGroupName
            };

            var newlyCreatedGamingGroupResult = new NewlyCreatedGamingGroupResult();
            var newGamingGroup = dataContext.Save<GamingGroup>(gamingGroup, currentUser);
            newlyCreatedGamingGroupResult.NewlyCreatedGamingGroup = newGamingGroup;
            //commit changes since we'll need the GamingGroup.Id
            dataContext.CommitAllChanges();

            var newlyCreatedPlayer = this.AssociateUserWithGamingGroup(currentUser, newGamingGroup);
            newlyCreatedGamingGroupResult.NewlyCreatedPlayer = newlyCreatedPlayer;

            new Task(() => eventTracker.TrackGamingGroupCreation(registrationSource)).Start();

            return newlyCreatedGamingGroupResult;
        }