Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
 public LevelCreator(InWordsDataContext context)
 {
     userWordPairRepository  = new UserWordPairRepository(context);
     creationRepository      = new CreationRepository(context);
     gameLevelRepository     = new GameLevelRepository(context);
     gameLevelWordRepository = new GameLevelWordRepository(context);
 }
Beispiel #4
0
 /// <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;
 }
Beispiel #5
0
        public async Task <int> DeleteCreation(int id)
        {
            Game game = await CreationRepository.FindById(id);

            int deletionsCount = await CreationRepository.Remove(game);

            return(deletionsCount);
        }
Beispiel #6
0
 public GameController(CreationRepository creationRepository,
                       GameLevelWordService gameLevelWordService,
                       GameService gameService, IMediator mediator)
 {
     this.mediator             = mediator;
     this.creationRepository   = creationRepository;
     this.gameLevelWordService = gameLevelWordService;
     this.gameService          = gameService;
 }
Beispiel #7
0
 public CreationService(CreationRepository сreationRepository,
                        CreationDescriptionRepository сreationDescriptionRepository)
 {
     CreationRepository            = сreationRepository;
     CreationDescriptionRepository = сreationDescriptionRepository;
 }