Exemple #1
0
        public IList <VideoDTO> ObterVideosApostila(VideoApostilaFiltroDTO filtro)
        {
            List <VideoDTO> v      = new List <VideoDTO>();
            var             videos = (IList <VideoDTO>)v;

            Parallel.For(0, filtro.IdsVideos.Count(), i =>
            {
                var codigo = filtro.IdsVideos[i];
                try
                {
                    if (IsVideoINTRO(codigo))
                    {
                        var v          = Convert.ToInt32(codigo.ToUpper().Replace("INTRO_", "").Trim());
                        var videoRep   = _vimeoRepository.GetVideoIntro(v);
                        videoRep       = _vimeoRepository.CreateVideoObject(videoRep, filtro.Matricula.ToString());
                        var video      = _vimeoRepository.ConvertToVideoDTO(videoRep);
                        video.KeyVideo = codigo;
                        videos.Add(video);
                    }
                    else
                    {
                        var vm = new VideoMiolo();

                        if (codigo.Contains("-"))
                        {
                            string[] CodigoApostilaID = codigo.Split('-');

                            vm.IDApostila  = int.Parse(CodigoApostilaID[0]);
                            vm.CodigoVideo = CodigoApostilaID[1];
                        }
                        else
                        {
                            vm.CodigoVideo = codigo;
                        }

                        var listVideos = GetByVideoMiolo(vm, filtro.Matricula.ToString(), (Aplicacoes)filtro.IdAplicacao, filtro.AppVersion);

                        foreach (var v in listVideos)
                        {
                            v.KeyVideo   = codigo;
                            var videoDTO = new VideoDTO()
                            {
                                Ativo              = v.Ativo,
                                DataModificacao    = v.DataModificacao,
                                Descricao          = v.Descricao,
                                DownVote           = v.DownVote,
                                DteDataModificacao = v.DteDataModificacao,
                                Duracao            = v.Duracao,
                                ExerciciosVideo    = v.ExerciciosVideo,
                                ExisteAmazon       = v.ExisteAmazon,
                                Guid           = v.Guid,
                                ID             = v.ID,
                                KeyVideo       = v.KeyVideo,
                                Links          = v.Links,
                                Nome           = v.Nome,
                                QuestaoDoVideo = v.QuestaoDoVideo,
                                StatusID       = v.StatusID,
                                Tamanho        = v.Tamanho,
                                Tema           = v.Tema,
                                Thumb          = v.Thumb,
                                UnixCriacao    = v.UnixCriacao,
                                UpVote         = v.UpVote,
                                Url            = v.Url,
                                VideoId        = v.VideoId,
                                VimeoId        = v.VimeoId,
                                VotadoDownvote = v.VotadoDownvote,
                                VotadoUpvote   = v.VotadoUpvote
                            };
                            videos.Add(videoDTO);
                        }
                    }
                }
                catch
                {
                    var vid      = new Video();
                    vid.KeyVideo = filtro.IdsVideos[i];
                    videos.Add(_vimeoRepository.ConvertToVideoDTO(vid));
                }
            });
            return(videos);
        }