private int?CreateBoardGameGeekGameDefinition(int?boardGameGeekGameDefinitionId, ApplicationUser currentUser) { if (boardGameGeekGameDefinitionId.HasValue) { boardGameGeekGameDefinitionId = boardGameGeekGameDefinitionCreator.CreateBoardGameGeekGameDefinition( boardGameGeekGameDefinitionId.Value, currentUser); } return(boardGameGeekGameDefinitionId); }
private BoardGameGeekGameDefinition CreateBoardGameGeekGameDefinition(int?boardGameGeekGameDefinitionId) { BoardGameGeekGameDefinition newBoardGameGeekGameDefinition = null; if (boardGameGeekGameDefinitionId.HasValue) { newBoardGameGeekGameDefinition = _boardGameGeekGameDefinitionCreator.CreateBoardGameGeekGameDefinition( boardGameGeekGameDefinitionId.Value); } return(newBoardGameGeekGameDefinition); }
private BoardGameGeekGameDefinition CreateBoardGameGeekGameDefinition(int?boardGameGeekGameDefinitionId, ApplicationUser currentUser) { BoardGameGeekGameDefinition newBoardGameGeekGameDefinition = null; if (boardGameGeekGameDefinitionId.HasValue) { newBoardGameGeekGameDefinition = _boardGameGeekGameDefinitionCreator.CreateBoardGameGeekGameDefinition( boardGameGeekGameDefinitionId.Value); } return(newBoardGameGeekGameDefinition); }
public override GameDefinition Execute(CreateGameDefinitionRequest createGameDefinitionRequest, ApplicationUser currentUser, IDataContext dataContextWithTransaction) { ValidateNotNull(createGameDefinitionRequest); ValidateGameDefinitionNameIsNotNullOrWhitespace(createGameDefinitionRequest.Name); int gamingGroupId = createGameDefinitionRequest.GamingGroupId ?? currentUser.CurrentGamingGroupId; BoardGameGeekGameDefinition boardGameGeekGameDefinition = null; if (createGameDefinitionRequest.BoardGameGeekGameDefinitionId.HasValue) { boardGameGeekGameDefinition = _boardGameGeekGameDefinitionCreator.CreateBoardGameGeekGameDefinition( createGameDefinitionRequest.BoardGameGeekGameDefinitionId.Value, currentUser); } var existingGameDefinition = dataContextWithTransaction.GetQueryable <GameDefinition>() .FirstOrDefault(game => game.GamingGroupId == gamingGroupId && game.Name == createGameDefinitionRequest.Name); if (existingGameDefinition == null) { var newGameDefinition = new GameDefinition { Name = createGameDefinitionRequest.Name, BoardGameGeekGameDefinitionId = boardGameGeekGameDefinition?.Id, Description = createGameDefinitionRequest.Description, GamingGroupId = gamingGroupId }; new Task(() => _eventTracker.TrackGameDefinitionCreation(currentUser, createGameDefinitionRequest.Name)).Start(); return(dataContextWithTransaction.Save(newGameDefinition, currentUser)); } ValidateNotADuplicateGameDefinition(existingGameDefinition); existingGameDefinition.Active = true; existingGameDefinition.BoardGameGeekGameDefinitionId = boardGameGeekGameDefinition?.Id; if (!string.IsNullOrWhiteSpace(createGameDefinitionRequest.Description)) { existingGameDefinition.Description = createGameDefinitionRequest.Description; } return(dataContextWithTransaction.Save(existingGameDefinition, currentUser)); }