Example #1
0
        private void GetData()
        {
            if (string.IsNullOrWhiteSpace(username))
            {
                return;
            }

            var currentStreams = api.Streams(username);

            if (!currentStreams.HasError)
            {
                var streamsbuffer = new ObservableCollection <LiveStreamViewModel>();

                foreach (var stream in currentStreams.Data.Streams)
                {
                    var temp = new LiveStreamViewModel()
                    {
                        Logo            = stream.Channel.Logo,
                        DisplayName     = stream.Channel.DisplayName,
                        Preview         = stream.Preview.Small,
                        LiveUrl         = stream.Channel.Url,
                        GameName        = stream.Game,
                        PreviewLarge    = stream.Preview.Large,
                        GameLogo        = stream.Preview.Medium,
                        PreviewTemplate = StreamPreviewTemplateUrl.Convert(stream.Preview.Template),
                        ViewerCount     = stream.Viewers,
                    };

                    streamsbuffer.Add(temp);
                }
                StreamViewModel.LiveStreams = new ObservableCollection <LiveStreamViewModel>(streamsbuffer.OrderBy(o => o.ViewerCount));
                StreamViewModel.RaisePropertyChangedOn(() => StreamViewModel.LiveStreams);
            }
        }
Example #2
0
        public ActionResult Criar(LiveStreamViewModel viewModel)
        {
            var noticia = new Noticias
            {
                titulo          = viewModel.Legenda,
                dataCadastro    = DateTime.Now,
                dataAtualizacao = DateTime.Now,
                texto           = viewModel.Legenda,
                chamada         = viewModel.Legenda,
                excluido        = true,
                liberado        = false
            };

            db.LiveStreamings.Add(new LiveStreamings
            {
                Ativo             = false,
                DataCadastro      = DateTime.Now,
                DataFinalizacao   = viewModel.DataFinalizacao,
                CodigoTransmissao = viewModel.CodigoTransmissao,
                Legenda           = viewModel.Legenda,
                Noticias          = noticia
            });

            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Example #3
0
        public ActionResult LiveStream()
        {
            Service service = new Service();

            var userId = User.Identity.GetUserId();

            ICollection <LivePost>   livePosts   = service.GetLivePosts();
            ICollection <LiveStream> liveStreams = service.GetLiveStream(userId);
            var settings   = service.GetSettings(userId);
            var jeepModels = service.GetAllJeepModels();

            LiveStreamViewModel model = new LiveStreamViewModel(livePosts, liveStreams)
            {
                Settings = settings,
                Models   = jeepModels
            };

            if (TempData["Message"] != null)
            {
                ViewBag.Message = TempData["Message"];
            }
            ViewBag.Header = "Success!";

            return(View(model));
        }
Example #4
0
        public ActionResult Discover()
        {
            Service service = new Service();

            ICollection <LiveStream> publicStream = service.GetPublicStream();

            LiveStreamViewModel model = new LiveStreamViewModel(publicStream);

            return(View(model));
        }
Example #5
0
        public ActionResult LiveAtual()
        {
            string key = primeKey + "Index:LiveAtual:TLiveStreaming";

            LiveStreamViewModel retorno = null;

            Func <object, LiveStreamViewModel> funcao = t => LiveAtualDB();

            retorno = RedisService.GetOrSetToRedis(key, funcao, 60);

            return(Json(retorno, JsonRequestBehavior.AllowGet));
        }
Example #6
0
        public ActionResult Editar(LiveStreamViewModel viewModel)
        {
            var liveStream = db.LiveStreamings.Find(viewModel.Id);

            liveStream.Legenda           = viewModel.Legenda;
            liveStream.CodigoTransmissao = viewModel.CodigoTransmissao;

            db.Entry(liveStream).State = EntityState.Modified;

            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Example #7
0
        public ActionResult TimelineSettingsPartial()
        {
            Service service = new Service();

            var userId = User.Identity.GetUserId();

            LiveStreamViewModel model = new LiveStreamViewModel
            {
                Settings = service.GetSettings(userId),
                Models   = service.GetAllJeepModels()
            };

            return(View("~/Views/Shared/_TimelineSettingsPartial.cshtml", model));
        }