public IViewComponentResult Invoke(SeoType Type, int Id, string Title = null, string Des = null, string Img = null) { var model = new SeoModel(); ISeoDomain seo = null; if (Id == 0) { return(View(new SeoModel() { TitleSEO = Title, DescriptionSEO = Des, ImageSEO = Img })); } Type typeSer = null; switch (Type) { case SeoType.Home: typeSer = typeof(IInfoService); break; case SeoType.Category: typeSer = typeof(ICateService); break; case SeoType.Detail: typeSer = typeof(IProductService); break; case SeoType.Discount: { Title = "Sản phẩm khuyến mãi"; typeSer = typeof(IInfoService); break; } case SeoType.Search: { Title = "Kết quả tìm kiếm"; typeSer = typeof(IInfoService); break; } } if (typeSer != null) { var service = (ISeoService)HttpContext.RequestServices.GetService(typeSer); seo = service.GetSeo(Id); } if (seo != null) { model.TitleSEO = Title ?? seo.SeoTitle; model.DescriptionSEO = Des ?? seo.SeoDescription; model.ImageSEO = Img ?? seo.SeoImage; } return(View(model)); }
public IActionResult DetailIndex(SeoType type, int index, [FromServices] IIndex <SeoType, IBuildSeo> seoBuilder) { var provider = seoBuilder[type]; var urls = provider.GetUrls(_configurationService.GetSiteName() == ConfigurationService.Site.Frymo, index); var ns = new XmlSerializerNamespaces(); ns.Add("", ""); return(new FileCallbackResult("application/xml", async(stream, context) => { using var writer = XmlWriter.Create(stream, _xmlWriterSettings); var serializer = new XmlSerializer(typeof(SitemapNode)); var i = 0; await writer.WriteStartDocumentAsync(); await writer.WriteStartElementAsync(null, "urlset", null); // writer.WriteStartElement("urlset", // "http://www.sitemaps.org/schemas/sitemap/0.9"); await writer.WriteAttributeStringAsync("xmlns", "image", null, "http://www.google.com/schemas/sitemap-image/1.1"); await writer.WriteAttributeStringAsync("v", "xmlns", null, "http://www.sitemaps.org/schemas/sitemap/0.9"); //writer.WriteAttributeString("xmlns", "video", null, "http://www.google.com/schemas/sitemap-video/1.1"); //writer.WriteAttributeString("xmlns", "xhtml", null, "http://www.w3.org/1999/xhtml"); //writer.WriteAttributeString("xmlns:xhtml", "http://www.w3.org/1999/xhtml"); // for lang support foreach (var url in urls) { i++; serializer.Serialize(writer, url, ns); if (i % 100 == 0) { await writer.FlushAsync(); } } await writer.WriteEndElementAsync(); await writer.WriteEndDocumentAsync(); await writer.FlushAsync(); })); }
public SiteMapCountDto(SeoType type, int count) { Type = type; Count = count; }