Example #1
0
        public async Task <IActionResult> SaveVideo([FromBody] VideosDto video)
        {
            try
            {
                await repository.SaveVideo(mapper.Map <Videos>(video));

                return(Ok());
            }
            catch (Exception)
            {
                return(BadRequest(new { Message = "Error processing your request." }));
            }
        }
Example #2
0
        public List <VideosDto> GetVideos(int tmdbId)
        {
            ResultContainer <Video> tmdbVideos = _client.GetMovieVideosAsync(tmdbId).Result;
            List <VideosDto>        videos     = new List <VideosDto>();

            string urlPrefix = "https://www.youtube.com/embed/";

            foreach (var video in tmdbVideos.Results)
            {
                if (video.Site == "YouTube")
                {
                    VideosDto newVideo = new VideosDto()
                    {
                        Key = $"{urlPrefix}{video.Key}"
                    };
                    videos.Add(newVideo);
                }
            }

            return(videos);
        }