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 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 CreationService(CreationRepository сreationRepository, CreationDescriptionRepository сreationDescriptionRepository) { CreationRepository = сreationRepository; CreationDescriptionRepository = сreationDescriptionRepository; }