Exemple #1
0
        public ActionResult <EpisodeDto> GetEpisode(int episodeId)
        {
            var episodeFromRepo = _episodeRepository.GetEpisode(episodeId);

            if (episodeFromRepo == null)
            {
                return(NotFound());
            }
            return(Ok(_mapper.Map <EpisodeDto>(episodeFromRepo)));
        }
Exemple #2
0
        public async Task <IActionResult> Connect(string id, [FromQuery] int episodeId)
        {
            var episode = await _episodeRepository.GetEpisode(episodeId);

            var videoInfo = episode?.VideoInfo;

            if (videoInfo == null)
            {
                return(BadRequest("The requested video could not be found"));
            }
            var devices = await GetReceivers();

            var target = devices.FirstOrDefault(rcvr => rcvr.Id == id);

            if (target == null)
            {
                return(BadRequest("That device is not available to cast."));
            }
            var sender = new Sender();
            await sender.ConnectAsync(target);

            var mediaChannel = sender.GetChannel <IMediaChannel>();
            await sender.LaunchAsync(mediaChannel);

            var mediaStatus = await mediaChannel.LoadAsync(
                new MediaInformation()
            {
                ContentId   = $"http://192.168.0.119:5000/{videoInfo.FilePath}",
                ContentType = "video/mp4",
            });

            return(Ok(mediaStatus));
        }
        public async Task <EpisodeCharacters> GetEpisodeCharacters(int episodeId)
        {
            var episode = await _episodeRepository.GetEpisode(episodeId);

            if (episode == null)
            {
                throw new KeyNotFoundException($"The episode with ${episodeId} does not exists");
            }
            var episodeCharacters = _episodeRepository.GetEpisodesCharacters(episodeId).ToList();
            var characters        = _characterRepository.GetAllCharacters().Where(x => episodeCharacters.Select(a => a.CharacterId).Contains(x.Id));

            return(new EpisodeCharacters(episodeId, episode.Name, characters.Select(character => character.Name)));
        }
        public async Task <IActionResult> UpdateEpisode([FromBody] EpisodeViewModel episode)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (episode.Id == default)
            {
                return(BadRequest("An episode ID must be provided."));
            }
            var entity = await _episodeRepository.GetEpisode(episode.Id);

            if (entity == null)
            {
                return(BadRequest("No episode could be found to update."));
            }
            _mapper.Map(episode, entity);
            await _episodeRepository.SaveChanges();

            return(new JsonResult(episode));
        }
        public StarWarsQuery(ICharacterRepository characterRepository, IFactionRepository factionRepository, IEpisodeRepository episodeRepository, ICharacterGroupRepository characterGroupRepository, ICharacterTypeRepository characterTypeRepository, IStarshipRepository starshipRepository)
        {
            #region Faction
            Field <ListGraphType <FactionQLType> >(
                "factions",
                //arguments: new QueryArguments(
                //    new QueryArgument<IntGraphType> { Name = "id", Description = "faction id" }
                //),
                resolve: context => factionRepository.GetFaction().Result
                );

            Field <FactionQLType>(
                "faction",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "id", Description = "faction id"
            }
                    ),
                resolve: context => factionRepository.GetFaction(context.GetArgument <int>("id")).Result
                );
            #endregion

            #region Episode
            Field <EpisodeQLType>(
                "episode",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "id", Description = "episode id"
            }
                    ),
                resolve: context => episodeRepository.GetEpisode(context.GetArgument <int>("id")).Result
                );
            Field <ListGraphType <EpisodeQLType> >(
                "episodes",
                //arguments: new QueryArguments(
                //    new QueryArgument<NonNullGraphType<IntGraphType>> { Name = "id", Description = "episode id" }
                //),
                resolve: context => episodeRepository.GetEpisode().Result
                );
            #endregion

            #region Character
            Field <ListGraphType <CharacterQLType> >(
                "characters",
                //arguments: new QueryArguments(
                //    new QueryArgument<NonNullGraphType<IntGraphType>> { Name = "id", Description = "character id" }
                //),
                resolve:
                context => characterRepository.GetCharacter().Result
                );

            Field <CharacterQLType>(
                "character",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "id", Description = "character id"
            }
                    ),
                resolve:
                context => characterRepository.GetCharacter(context.GetArgument <int>("id")).Result
                );
            #endregion

            #region Starship
            Field <StarshipQLType>(
                "starships",
                //arguments: new QueryArguments(
                //    new QueryArgument<NonNullGraphType<IntGraphType>> { Name = "id", Description = "starship id" }
                //),
                resolve: context => starshipRepository.GetStarship().Result
                );

            Field <StarshipQLType>(
                "starship",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "id", Description = "starship id"
            }
                    ),
                resolve: context => starshipRepository.GetStarship(context.GetArgument <int>("id")).Result
                );
            #endregion
        }
 public Episode GetEpisode(int id)
 {
     return(_episodeRepository.GetEpisode(id));
 }
 public IActionResult GetEpisode(int id)
 {
     return(Ok(_episodeRepository.GetEpisode(id)));
 }