//private void getTemperature(int locationId) //{ // var objCidade = LocalSrv.GetCidadeByIdCached(locationId); // var obj = WeatherSrv.GetWeather(objCidade.Id); // ViewBag.City = obj == null ? string.Empty : obj.City ?? string.Empty; // ViewBag.Description = obj == null ? string.Empty : obj.Description ?? string.Empty; // ViewBag.Icon = obj == null ? string.Empty : obj.Icon ?? string.Empty; // ViewBag.Temperature = obj == null ? string.Empty : obj.Temperature == 0 ? string.Empty : obj.Temperature.ToString(); //} private DestaqueVideoViewModel GetRegionHighlights(int microregionId) { var objModel = new DestaqueVideoViewModel { Url = "noticias", Titulo = "Notícias", Sections = new List <DestaqueVideoViewModel.VideoSection>() }; var lstMicroregions = Microregiao.GetAllByStatus(true); foreach (var microregion in lstMicroregions) { var section = new DestaqueVideoViewModel.VideoSection { Url = microregion.Url, Title = microregion.Nome, Videos = NoticiaSrv.GetLastestVideoNewsByMicroregion(4, microregion.Id).Select(VideoModel.Map), ButtonText = "Ver mais", ButtonUrl = $"/videos/{microregion.Url}", Selected = microregionId == microregion.Id }; objModel.Sections.Add(section); } if (objModel.Sections.All(s => !s.Selected)) { objModel.Sections.First().Selected = true; } return(objModel); }
private DestaqueComTags GetDestaquesComtags(Section section, Home home, ref List <int> notInList) { if (!section.Editorialid.HasValue) { return(null); } var objEditorial = Editorial.Load(section.Editorialid.Value); var lstHighlights = Noticia.GetBySection(5, section, (home.Status || Section.SuaRegiao.Id == section.Id) ? home.Id : 1, ref notInList, true).ToList(); var objDestaqueComTags = new DestaqueComTags { Key = section.Key, Theme = section.Theme, Titulo = section.Desc, LinkTitulo = section.Url, LinkImgTitulo = objEditorial.IconUrl, Highlights = lstHighlights, Tags = NoticiaSrv.GetTagsBySection(section.Id, home.Id).ToList(), isLazy = !(section.Id == 1) //1 = sua região }; return(objDestaqueComTags); }
private string Replace(Noticia objNews, ControllerContext context) { var html = new HtmlDocument(); html.LoadHtml(objNews.Conteudo); #region Subtitles var galleries = html.DocumentNode.Descendants("span").Where(p => p.GetAttributeValue("class", string.Empty) == "inner-gallery").ToList(); //objNews.Galerias = NoticiaSrv.GetGalleriesByTheNewsId(objNews.Id); if (galleries.Any()) { if (objNews.Galeria != null && objNews.Galeria.Imagens.Any()) { var galleryHtml = Util.RenderViewToString(context, "_GaleriaInterna", objNews, true); var galleryNode = HtmlNode.CreateNode(galleryHtml); foreach (var gallery in galleries) { gallery.ParentNode.ReplaceChild(galleryNode, gallery); } } else { foreach (var gallery in galleries) { gallery.ParentNode.ReplaceChild(null, gallery); } } } #endregion #region Scripts var scripts = html.DocumentNode.Descendants("span").Where(p => p.GetAttributeValue("class", string.Empty) == "inner-script").ToList(); foreach (var script in scripts) { int stripId; if (!int.TryParse(script.GetAttributeValue("data-script", string.Empty), out stripId)) { continue; } var objScript = NoticiaSrv.GetScriptById(stripId); var scriptNode = HtmlNode.CreateNode($"<span>{objScript.ContentScript}</span>"); script.ParentNode.ReplaceChild(scriptNode, script); } #endregion return(html.DocumentNode.OuterHtml); }
private List <Noticia> GetListOfNews(string categoria, DateTime startDate, DateTime endDate) { var lstNoticias = new List <Noticia>(); switch (categoria) { case "curitiba-regiao": lstNoticias = NoticiaSrv.GetLastestVideoNewsByMicroregion(null, MicroRegionEnum.Curitiba.GetHashCode(), startDate, endDate).ToList(); break; case "maringa-regiao": lstNoticias = NoticiaSrv.GetLastestVideoNewsByMicroregion(null, MicroRegionEnum.Maringa.GetHashCode(), startDate, endDate).ToList(); break; case "foz-do-iguacu-regiao": lstNoticias = NoticiaSrv.GetLastestVideoNewsByMicroregion(null, MicroRegionEnum.FozDoIguacu.GetHashCode(), startDate, endDate).ToList(); break; case "londrina-regiao": lstNoticias = NoticiaSrv.GetLastestVideoNewsByMicroregion(null, MicroRegionEnum.Londrina.GetHashCode(), startDate, endDate).ToList(); break; case "ponta-grossa-regiao": lstNoticias = NoticiaSrv.GetLastestVideoNewsByMicroregion(null, MicroRegionEnum.PontaGrossa.GetHashCode(), startDate, endDate).ToList(); break; case "noticias": lstNoticias = NoticiaSrv.GetLastestVideoNewsByEditory(null, EditorialEnum.Noticias.GetHashCode(), startDate, endDate).ToList(); break; case "esportes": lstNoticias = NoticiaSrv.GetLastestVideoNewsByEditory(null, EditorialEnum.Esportes.GetHashCode(), startDate, endDate).ToList(); break; case "entretenimento": lstNoticias = NoticiaSrv.GetLastestVideoNewsByEditory(null, EditorialEnum.Entretenimento.GetHashCode(), startDate, endDate).ToList(); break; case "where-curitiba": lstNoticias = NoticiaSrv.GetLastestVideoNewsByEditory(null, EditorialEnum.WhereCuritiba.GetHashCode(), startDate, endDate).ToList(); break; case "blogs": lstNoticias = NoticiaSrv.GetLastestVideoNewsByEditory(null, EditorialEnum.Blogs.GetHashCode(), startDate, endDate).ToList(); break; case "massa-news-live-on": lstNoticias = NoticiaSrv.GetLastestVideoNewsByTag(null, 752, startDate, endDate).ToList(); break; case "descobrindo-curitiba": lstNoticias = NoticiaSrv.GetLastestVideoNewsByTag(null, 754, startDate, endDate).ToList(); break; } return(lstNoticias); }
private DestaqueVideoViewModel GetVideoHighlights(Cidade objCidade, ref List <int> notInList) { var sectionDestaque = new DestaqueVideoViewModel.VideoSection { Url = "destaques", Title = "Destaques", Selected = true, Videos = Service.Models.Noticia.GetBySection(4, Section.Videos, 1, ref notInList, true).Take(4).Select(VideoModel.Map), ButtonText = "Ver todos os vídeos", ButtonUrl = "/videos" }; var sectionMicroregion = new DestaqueVideoViewModel.VideoSection { Url = objCidade.Url, Title = objCidade.Microregion.Nome, Videos = NoticiaSrv.GetLastestVideoNewsByMicroregion(4, objCidade.MicroregiaoId).Select(VideoModel.Map), ButtonText = "Ver todos os vídeos", ButtonUrl = "/videos" }; var sectionEsportes = new DestaqueVideoViewModel.VideoSection { Url = "esportes", Title = "Esportes", Videos = NoticiaSrv.GetLastestVideoNewsByEditory(4, EditorialEnum.Esportes.GetHashCode()).Select(VideoModel.Map), ButtonText = "Ver todos os vídeos", ButtonUrl = "/videos" }; var sectionEntretenimento = new DestaqueVideoViewModel.VideoSection { Url = "entretenimento", Title = "Entretenimento", Videos = NoticiaSrv.GetLastestVideoNewsByEditory(4, EditorialEnum.Entretenimento.GetHashCode()).Select(VideoModel.Map), ButtonText = "Ver todos os vídeos", ButtonUrl = "/videos" }; var sectionDescobrindoCuritiba = new DestaqueVideoViewModel.VideoSection { Url = "descobrindo-curitiba", Title = "Descobrindo Curitiba", Videos = NoticiaSrv.GetLastestVideoNewsByTag(4, 754).Select(VideoModel.Map), ButtonText = "Ver todos os vídeos", ButtonUrl = "/videos" }; var objModel = new DestaqueVideoViewModel { Titulo = "Vídeos", Sections = { sectionDestaque, sectionMicroregion, sectionEsportes, sectionEntretenimento, sectionDescobrindoCuritiba } }; return(objModel); }
private IEnumerable <Noticia> GetValuesOfBlogCategory(Noticia objNoticia) { var lastestNews = NoticiaSrv.GetLastestBlogNews(Constants.TakeNoticias, objNoticia.BlogId.Value); ViewBag.ActiveNav = objNoticia.Blog.Titulo; ViewBag.LinkActiveNav = $"/blogs/{objNoticia.CategoriaUrl}/{objNoticia.BlogUrl}/posts"; ViewBag.NavigationType = "blog"; ViewBag.ThemeValue = objNoticia.Categoria.Theme.Value; ViewBag.ScopeId = objNoticia.BlogId; ViewBag.Editorial = objNoticia.Categoria.Editorial; return(lastestNews); }
private DestaqueVideoViewModel GetDescobrindoCuritibaHighlights() { var section = new DestaqueVideoViewModel.VideoSection { Selected = true, Url = "descobrindo-curitiba", Title = "Descobrindo Curitiba", Videos = NoticiaSrv.GetLastestVideoNewsByTag(4, 754).Select(VideoModel.Map), ButtonText = "Ver mais", ButtonUrl = "/videos/descobrindo-curitiba" }; var objModel = new DestaqueVideoViewModel { Url = "descobrindo-curitiba", Titulo = "Descobrindo Curitiba", Sections = { section } }; return(objModel); }
private DestaqueVideoViewModel GetBlogHighlights() { var section = new DestaqueVideoViewModel.VideoSection { Selected = true, Url = "blogs", Title = "Blogs", Videos = NoticiaSrv.GetLastestVideoNewsByEditory(4, EditorialEnum.Blogs.GetHashCode()).Select(VideoModel.Map), ButtonText = "Ver mais", ButtonUrl = "/videos/blogs" }; var objModel = new DestaqueVideoViewModel { Url = "blogs", Titulo = "Blogs", Sections = { section } }; return(objModel); }
private DestaqueVideoViewModel GetNegociosDaTerraHighlights() { var section = new DestaqueVideoViewModel.VideoSection { Selected = true, Url = "negocios-da-terra", Title = "Negócios da Terra", Videos = NoticiaSrv.GetLastestVideoNewsByEditory(4, EditorialEnum.NegociosDaTerra.GetHashCode()).Select(VideoModel.Map), ButtonText = "Ver mais", ButtonUrl = "/videos/negocios-da-terra" }; var objModel = new DestaqueVideoViewModel { Url = "negocios-da-terra", Titulo = "Negócios da Terra", Sections = { section } }; return(objModel); }
public ActionResult LoadNexNavegationLink(string firstId, string scopeId, string publishDate, string navegationType) { var first = Convert.ToInt32(firstId.Split('-').Last()); int idScope; int.TryParse(scopeId, out idScope); var locationId = CookieFx.GetLocationId(Request); //Get the user city var objCidade = Cidade.Load(locationId); var objNoticia = (Noticia)null; switch (navegationType) { case "plantao": { //Sua Região objNoticia = NoticiaSrv.GetNextNewsCached(objCidade.MicroregiaoId, DateTime.Parse(publishDate), new[] { first }); break; } case "parana": { //Paraná objNoticia = NoticiaSrv.GetNextNewsCached(objCidade.MicroregiaoId, DateTime.Parse(publishDate), new[] { first }, true); break; } case "categoria": { //Categoria objNoticia = NoticiaSrv.GetNextNewsByCategoryCached(idScope, DateTime.Parse(publishDate), new[] { first }); break; } case "tags": { //Tags objNoticia = NoticiaSrv.GetNextNewsByTagCached(idScope, DateTime.Parse(publishDate), new[] { first }); break; } case "fotos": { //Fotos objNoticia = NoticiaSrv.GetNextNewsByFeaturedCached(Destaque.Galeria.Id, DateTime.Parse(publishDate), new[] { first }); break; } case "videos": //Videos objNoticia = NoticiaSrv.GetNextNewsByFeaturedCached(Destaque.Video.Id, DateTime.Parse(publishDate), new[] { first }); break; case "blog": { //Categoria objNoticia = NoticiaSrv.GetNextNewsByBlog(idScope, DateTime.Parse(publishDate), new[] { first }); break; } } return(objNoticia == null ? null : PartialView("_NavItem", new NoticiaNavItem(objNoticia, false))); }
private ActionResult LoadIndexNews(string editorialUrl, string categoryUrl, string blogurl, string newsUrl, bool isPreview = false) { try { // redirect where curitiba if (editorialUrl == "where-curitiba") { return(new RedirectResult("http://www.wherecuritiba.com.br", true)); } var newsId = ToolService.GetIdByUrl(Request.Url.ToString()); //Get the news object var objNoticia = null as Noticia; if (newsId.HasValue) { objNoticia = Noticia.Load(newsId.Value); } if (objNoticia == null) { objNoticia = Noticia.GetByUrl(newsUrl); } #region Validations //Redirect 301 to new url if (!isPreview) { #region Redirect var originUrl = Request.RawUrl.Remove(Request.RawUrl.Length - 5); if (objNoticia != null) { if (originUrl != objNoticia.UrlFull) { return(new RedirectResult($"{objNoticia.UrlFull}.html", true)); } } else { var redirectUrl = UrlRedirect.GetByUrl(originUrl); if (!string.IsNullOrEmpty(redirectUrl)) { return(new RedirectResult($"{redirectUrl}.html", true)); } } #endregion } if (objNoticia == null) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } if (objNoticia.Autores != null && objNoticia.Autores.Count() > 0) { //19 = Estadão, 65 = Folhapress var objAutorGoogleNews = objNoticia.Autores.Where(a => a.Id == 19 || a.Id == 65).FirstOrDefault(); ViewBag.isAutorGoogleNews = objAutorGoogleNews != null ? true : false; } //Caso a noticia for inativa responde com redirect permanente para a home if ((objNoticia.StatusId == Status.Inativa.Id || !objNoticia.Categoria.Status) && !isPreview) { return(new RedirectResult("/", true)); } //Caso a noticia for diferente de publicada responde com 404 if (objNoticia.StatusId != Status.Publicada.Id && !isPreview) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } #endregion //Recupera a origem var urlReferrer = Request.UrlReferrer?.AbsolutePath.TrimEnd('/') ?? string.Empty; //Ultimas Notícias var lastestNews = new List <Noticia>(); //Get the location id var locationId = CookieFx.GetLocationId(Request); //Get the user city var objCidade = Cidade.Load(locationId); //getTemperature(locationId); if (urlReferrer.StartsWith("/tag")) { var tagUrl = urlReferrer.Split('/').Last(); var tag = Tag.GetByUrl(tagUrl); if (tag == null) { return(null); } var isNewsWithTag = false; var newsWithTag = NoticiaSrv.GetTagsByNewsIdCached(objNoticia.Id); foreach (var item in newsWithTag) { if (item.Id == tag.Id) { isNewsWithTag = true; break; } } if (isNewsWithTag) { lastestNews = GetValuesOfTag(urlReferrer, objNoticia).ToList(); } else if (editorialUrl == "blogs") { lastestNews = GetValuesOfBlogCategory(objNoticia).ToList(); } else if (objNoticia.CidadeId.HasValue && objNoticia.CategoriaUrl.Equals("plantao")) { if (objNoticia.Cidade.MicroregiaoId == objCidade.MicroregiaoId) { lastestNews = GetValuesOfMyRegion(objCidade.MicroregiaoId, objNoticia).ToList(); } else if (objNoticia.Cidade.MicroregiaoId != objCidade.MicroregiaoId) { lastestNews = GetValuesOfParana(objCidade.MicroregiaoId, objNoticia).ToList(); } } else if (!objNoticia.CidadeId.HasValue && objNoticia.CategoriaUrl.Equals("plantao")) { lastestNews = GetValuesOfParana(objCidade.MicroregiaoId, objNoticia).ToList(); } else { lastestNews = GetValuesOfCategory(objNoticia).ToList(); } } else if (urlReferrer.StartsWith("/fotos")) { lastestNews = GetValuesOfGallery().ToList(); } else if (editorialUrl == "blogs") { lastestNews = GetValuesOfBlogCategory(objNoticia).ToList(); } else { if (objNoticia.CidadeId.HasValue) { //If the news has the category 'plantao' if (objNoticia.CategoriaUrl.Equals("plantao")) { if (objNoticia.Cidade.MicroregiaoId == objCidade.MicroregiaoId) { //Sua Região lastestNews = GetValuesOfMyRegion(objCidade.MicroregiaoId, objNoticia).ToList(); } else if (objNoticia.Cidade.MicroregiaoId != objCidade.MicroregiaoId) { //Paraná lastestNews = GetValuesOfParana(objCidade.MicroregiaoId, objNoticia).ToList(); } } else { //If the news is's category 'plantao lastestNews = GetValuesOfCategory(objNoticia).ToList(); } } else { //If the news has the category 'plantao' if (objNoticia.CategoriaUrl.Equals("plantao")) { //Paraná lastestNews = GetValuesOfParana(objCidade.MicroregiaoId, objNoticia).ToList(); } else { //If the news is's category 'plantao lastestNews = GetValuesOfCategory(objNoticia).ToList(); } } } //Habilita Comentários ViewBag.AllowComments = !isPreview; //Caso a notícia exista na lista é removida para evitar duplicidade if (lastestNews.Any(n => n.Id == objNoticia.Id)) { lastestNews.Remove(lastestNews.Single(n => n.Id == objNoticia.Id)); } //insere noticia na lista de notícias lastestNews.Insert(0, objNoticia); ViewBag.NavItems = lastestNews.Select(n => new NoticiaNavItem(n, lastestNews.IndexOf(n).Equals(0))); ViewBag.Lastest4News = lastestNews.Take(4).ToList(); //Set the list of categories if (objNoticia.Categoria.EditorialId == 4 && ViewBag.NavigationType == "categoria") { ViewBag.Categorias = NoticiaSrv.GetCategoriasByEditorial(objNoticia.Categoria.EditorialId); ViewBag.MenuCategoriaId = objNoticia.Categoria.CategoriaPaiId.HasValue ? objNoticia.Categoria.CategoriaPaiId : objNoticia.Categoria.Id; } ViewBag.AmpLink = $"{Constants.UrlWeb}/amp{objNoticia.UrlFull}.html"; /* base model defaults */ var model = new NoticiaModel { //Title = $"{objNoticia.Titulo} - Massa News {objNoticia.Cidade.Nome}", Description = $"{(objNoticia.Conteudo.Length > 220 ? Text.RemoveHtmlTags(objNoticia.Conteudo.Substring(0, 220) + "... Leia mais no Massa News!") : Text.RemoveHtmlTags(objNoticia.Conteudo) + " Leia no Massa News!")}", Robots = isPreview ? "noindex, nofollow" : "index, follow", Canonical = $"{Constants.UrlWeb}{objNoticia.UrlFull}.html", News = new NewsItemViewModel(objNoticia, ControllerContext) }; if (objNoticia.Cidade != null && !string.IsNullOrEmpty(objNoticia.Cidade.Nome)) { model.Title = $"{objNoticia.Titulo} - Massa News {objNoticia.Cidade.Nome}"; } else if (objNoticia.Blog != null && !string.IsNullOrEmpty(objNoticia.Blog.Titulo)) { model.Title = $"{objNoticia.Titulo} - {objNoticia.Blog.Titulo} - Massa News"; } else { model.Title = $"{objNoticia.Titulo} - Massa News"; } if (!string.IsNullOrEmpty(objNoticia.ImgLg)) { model.ImgOpenGraph = $"{Constants.UrlDominioEstaticoUploads}/{"noticias"}/{objNoticia.ImgLg}"; } else if (objNoticia.Blog != null) { model.ImgOpenGraph = $"{Constants.UrlWeb}/content/images/avatar/blogs/{objNoticia.Blog.Url}.jpg"; } // Página ViewBag.Pagina = "interna"; // ID ViewBag.Id = objNoticia.Id; // Editoria ViewBag.EditoriaUrl = objNoticia.Categoria.Editorial.Url; ViewBag.EditoriaTitulo = objNoticia.Categoria.Editorial.Titulo; // Categoria ViewBag.Categoria = objNoticia.CategoriaUrl; //Formata Noticia Site Antigo Negocio da Terra if (editorialUrl == "negocios-da-terra" && objNoticia.DataPublicacao < new DateTime(2017, 09, 12)) { var aux = model.News.News.Conteudo.Split('\n'); model.News.News.Conteudo = ""; foreach (var item in aux) { if (!String.IsNullOrEmpty(item)) { model.News.News.Conteudo = model.News.News.Conteudo + "<p>" + item + "</p>"; } } } return(View("index", model)); } catch (Exception ex) { var vars = new Dictionary <string, string> { { "Editorial", editorialUrl }, { "Category", categoryUrl }, { "NewsUrl", newsUrl } }; NewRelic.Api.Agent.NewRelic.NoticeError(ex, vars); throw; } }
public ActionResult LoadNexNavegationLink(string firstId, string sectionUrl, string publishDate) { var firstItemId = Convert.ToInt32(firstId.Split('-').Last()); var endDate = Convert.ToDateTime(publishDate); var lstNoticias = new List <Noticia>(); const int take = 20; switch (sectionUrl) { case "curitiba-regiao": lstNoticias = NoticiaSrv.GetLastestVideoNewsByMicroregion(take, MicroRegionEnum.Curitiba.GetHashCode(), null, endDate).ToList(); break; case "maringa-regiao": lstNoticias = NoticiaSrv.GetLastestVideoNewsByMicroregion(take, MicroRegionEnum.Maringa.GetHashCode(), null, endDate).ToList(); break; case "foz-do-iguacu-regiao": lstNoticias = NoticiaSrv.GetLastestVideoNewsByMicroregion(take, MicroRegionEnum.FozDoIguacu.GetHashCode(), null, endDate).ToList(); break; case "londrina-regiao": lstNoticias = NoticiaSrv.GetLastestVideoNewsByMicroregion(take, MicroRegionEnum.Londrina.GetHashCode(), null, endDate).ToList(); break; case "ponta-grossa-regiao": lstNoticias = NoticiaSrv.GetLastestVideoNewsByMicroregion(take, MicroRegionEnum.PontaGrossa.GetHashCode(), null, endDate).ToList(); break; case "noticias": lstNoticias = NoticiaSrv.GetLastestVideoNewsByEditory(take, EditorialEnum.Noticias.GetHashCode(), null, endDate).ToList(); break; case "esportes": lstNoticias = NoticiaSrv.GetLastestVideoNewsByEditory(take, EditorialEnum.Esportes.GetHashCode(), null, endDate).ToList(); break; case "entretenimento": lstNoticias = NoticiaSrv.GetLastestVideoNewsByEditory(take, EditorialEnum.Entretenimento.GetHashCode(), null, endDate).ToList(); break; case "negocios-da-terra": lstNoticias = NoticiaSrv.GetLastestVideoNewsByEditory(take, EditorialEnum.NegociosDaTerra.GetHashCode(), null, endDate).ToList(); break; case "where-curitiba": lstNoticias = NoticiaSrv.GetLastestVideoNewsByEditory(take, EditorialEnum.WhereCuritiba.GetHashCode(), null, endDate).ToList(); break; case "blogs": lstNoticias = NoticiaSrv.GetLastestVideoNewsByEditory(take, EditorialEnum.Blogs.GetHashCode(), null, endDate).ToList(); break; } //Remove iten if (lstNoticias.Any(n => n.Id == firstItemId)) { lstNoticias.Remove(lstNoticias.Single(n => n.Id == firstItemId)); } //Remove a ultima if (lstNoticias.Any(n => n.DataPublicacao == endDate)) { lstNoticias.Remove(lstNoticias.Single(n => n.DataPublicacao == endDate)); } return(PartialView("_LastNewsItem", lstNoticias.ToList().Select(MenuItemModel.Map).ToList())); }
//[Route("Videos/{section}/{url}.html")] public ActionResult Interna(string url) { #region redirect var redirectUrl = !string.IsNullOrEmpty(NoticiaSrv.GetRedirectUrlContains(url)) ? NoticiaSrv.GetRedirectUrlContains(url).Split('/')[3] : null; if (!string.IsNullOrEmpty(redirectUrl) && !redirectUrl.Equals(url)) { return(new RedirectResult($"/videos/{redirectUrl}.html", true)); } #endregion var noticiaUrl = redirectUrl ?? url; //Get the news object var objNoticia = Noticia.GetByUrl(noticiaUrl); var objVideo = VideoModel.Map(objNoticia); #region Validations //Redirect 301 to new url var originUrl = $"/videos/{noticiaUrl}.html"; if (objNoticia != null) { if (originUrl != objVideo.InternaUrl) { return(new RedirectResult(objVideo.InternaUrl, true)); } } //Return not found if (objNoticia == null) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } //Caso a noticia for inativa responde com redirect permanente para a home if ((objNoticia.StatusId == Status.Inativa.Id || !objNoticia.Categoria.Status)) { return(new RedirectResult("/", true)); } //Caso a noticia for diferente de publicada responde com 404 if (objNoticia.StatusId != Status.Publicada.Id) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } #endregion var model = new VideoInterna { //Base Title = $"Vídeo: {objNoticia.Titulo} - Massa News", Description = $"{(objNoticia.Conteudo.Length > 220 ? Text.RemoveHtmlTags(objNoticia.Conteudo.Substring(0, 220) + "... Veja o vídeo no Massa News!") : Text.RemoveHtmlTags(objNoticia.Conteudo) + " Veja o vídeo no Massa News!")}", Robots = "noindex, follow", Canonical = $"{objNoticia.UrlFull}.html", Url = $"{objVideo.InternaUrl}", //Model Video = objVideo, SectionUrl = objVideo.Section, SectionLink = $"/videos/{objVideo.Section}", CloseLink = (Request.UrlReferrer != null && Request.UrlReferrer.ToString().StartsWith(Constants.UrlWeb)) ? "#" : $"/videos/{objVideo.Section}" }; if (!string.IsNullOrEmpty(objNoticia.ImgLg)) { model.ImgOpenGraph = $"{Constants.UrlDominioEstaticoUploads}/{"noticias"}/{objNoticia.ImgLg}"; } var lstNoticias = new List <Noticia>(); const int take = 20; switch (objVideo.Section) { case "curitiba-regiao": lstNoticias = NoticiaSrv.GetLastestVideoNewsByMicroregion(take, MicroRegionEnum.Curitiba.GetHashCode()).ToList(); model.SectionTitle = "Curitiba e região"; break; case "maringa-regiao": lstNoticias = NoticiaSrv.GetLastestVideoNewsByMicroregion(take, MicroRegionEnum.Maringa.GetHashCode()).ToList(); model.SectionTitle = "Maringá e região"; break; case "foz-do-iguacu-regiao": lstNoticias = NoticiaSrv.GetLastestVideoNewsByMicroregion(take, MicroRegionEnum.FozDoIguacu.GetHashCode()).ToList(); model.SectionTitle = "Foz do Iguaçu e região"; break; case "londrina-regiao": lstNoticias = NoticiaSrv.GetLastestVideoNewsByMicroregion(take, MicroRegionEnum.Londrina.GetHashCode()).ToList(); model.SectionTitle = "Londrina e região"; break; case "ponta-grossa-regiao": lstNoticias = NoticiaSrv.GetLastestVideoNewsByMicroregion(take, MicroRegionEnum.PontaGrossa.GetHashCode()).ToList(); model.SectionTitle = "Ponta Grossa e região"; break; case "noticias": lstNoticias = NoticiaSrv.GetLastestVideoNewsByEditory(take, EditorialEnum.Noticias.GetHashCode()).ToList(); model.SectionTitle = "Notícias"; break; case "esportes": lstNoticias = NoticiaSrv.GetLastestVideoNewsByEditory(take, EditorialEnum.Esportes.GetHashCode()).ToList(); model.SectionTitle = "Esportes"; break; case "entretenimento": lstNoticias = NoticiaSrv.GetLastestVideoNewsByEditory(take, EditorialEnum.Entretenimento.GetHashCode()).ToList(); model.SectionTitle = "Entretenimento"; break; case "negocios-da-terra": lstNoticias = NoticiaSrv.GetLastestVideoNewsByEditory(take, EditorialEnum.NegociosDaTerra.GetHashCode()).ToList(); model.SectionTitle = "Negócios da Terra"; break; case "where-curitiba": lstNoticias = NoticiaSrv.GetLastestVideoNewsByEditory(take, EditorialEnum.WhereCuritiba.GetHashCode()).ToList(); model.SectionTitle = "Where Curitiba"; break; case "blogs": lstNoticias = NoticiaSrv.GetLastestVideoNewsByEditory(take, EditorialEnum.Blogs.GetHashCode()).ToList(); model.SectionTitle = "Blogs"; break; case "massa-news-live-on": lstNoticias = NoticiaSrv.GetLastestVideoNewsByTag(take, 752).ToList(); model.SectionTitle = "Massa News Live On"; break; case "descobrindo-curitiba": lstNoticias = NoticiaSrv.GetLastestVideoNewsByTag(take, 754).ToList(); model.SectionTitle = "Descobrindo Curitiba"; break; } //Remove iten if (lstNoticias.Any(n => n.Id == objNoticia.Id)) { lstNoticias.Remove(lstNoticias.Single(n => n.Id == objNoticia.Id)); } //Add current iten at the fist position lstNoticias.Insert(0, objNoticia); model.MenuItems = lstNoticias.ToList().Select(MenuItemModel.Map).ToList(); model.MenuItems.First().Selected = true; //ViewBag's ViewBag.IsVideo = true; ViewBag.IsInternaVideo = true; return(View(model)); }