public CreationInfo GetCreationInfo(int id) { // find game information Game game = CreationRepository .GetWithInclude(n => n.Creator) .SingleOrDefault(c => c.GameId.Equals(id)); if (game == null) { return(null); } // select game description from descriptions repository List <CreationDescription> descriptionList = CreationDescriptionRepository.GetWhere(cd => cd.CreationId == game.GameId).ToList(); // form descriptions infos List <DescriptionInfo> descriptions = GetDescriptionInfos(descriptionList); var creationInfo = new CreationInfo { CreatorId = game.CreatorId, CreatorNickname = game.Creator.NickName, Descriptions = descriptions }; return(creationInfo); }
public async Task <Game> AddCreationInfoAsync(CreationInfo creationInfo) { if (creationInfo.CreatorId == null) { throw new ArgumentNullException($"{nameof(creationInfo)} creator not found"); } var creation = new Game { CreatorId = (int)creationInfo.CreatorId }; creation = await CreationRepository.CreateAsync(creation).ConfigureAwait(false); IEnumerable <CreationDescription> creationDescriptions = creationInfo.Descriptions.Select(cd => new CreationDescription { CreationId = creation.GameId, LanguageId = cd.LangId, Title = cd.Title, Description = cd.Description }); await CreationDescriptionRepository.Create(creationDescriptions.ToArray()).ConfigureAwait(false); return(creation); }
public LevelCreator(InWordsDataContext context) { userWordPairRepository = new UserWordPairRepository(context); creationRepository = new CreationRepository(context); gameLevelRepository = new GameLevelRepository(context); gameLevelWordRepository = new GameLevelWordRepository(context); }
/// <summary> /// Basic constructor /// </summary> /// <param name="creationService"></param> /// <param name="creationRepository"></param> /// <param name="gameLevelService"></param> public GameService(CreationService creationService, CreationRepository creationRepository, GameLevelService gameLevelService) { this.creationService = creationService; this.creationRepository = creationRepository; this.gameLevelService = gameLevelService; }
public async Task <int> DeleteCreation(int id) { Game game = await CreationRepository.FindById(id); int deletionsCount = await CreationRepository.Remove(game); return(deletionsCount); }
public GameController(CreationRepository creationRepository, GameLevelWordService gameLevelWordService, GameService gameService, IMediator mediator) { this.mediator = mediator; this.creationRepository = creationRepository; this.gameLevelWordService = gameLevelWordService; this.gameService = gameService; }
public CreationService(CreationRepository сreationRepository, CreationDescriptionRepository сreationDescriptionRepository) { CreationRepository = сreationRepository; CreationDescriptionRepository = сreationDescriptionRepository; }