public ActionResult SiteMap() { List <SitemapItem> veriler = new List <SitemapItem>(); veriler.Add(new SitemapItem() { loc = Url.Action("index", "home", null, "http"), lastmod = DateTime.Now, changefreq = "daily", priority = "1" }); veriler.Add(new SitemapItem() { loc = Url.Action("about", "home", null, "http"), lastmod = DateTime.Now, changefreq = "daily", priority = "1" }); veriler.Add(new SitemapItem() { loc = Url.Action("new", "forum", new { page = 1 }, "http"), lastmod = DateTime.Now, changefreq = "daily", priority = "1" }); veriler.Add(new SitemapItem() { loc = Url.Action("popular", "forum", new { page = 1 }, "http"), lastmod = DateTime.Now, changefreq = "daily", priority = "1" }); veriler.Add(new SitemapItem() { loc = Url.Action("search", "forum", null, "http"), lastmod = DateTime.Now, changefreq = "daily", priority = "1" }); veriler.Add(new SitemapItem() { loc = Url.Action("users", "account", new { type = "all", page = 1 }, "http"), lastmod = DateTime.Now, changefreq = "daily", priority = "1" }); foreach (var category in Db.category.Where(x => x.IsApproval == true)) { veriler.Add(new SitemapItem() { loc = Url.Action("category", "forum", new { id = category.Id, seo = category.Seo }, "http"), lastmod = DateTime.Now, changefreq = "daily", priority = "1" }); } foreach (var forum in Db.forum.Where(x => x.IsApproval == true && x.category.IsApproval == true).ToList()) { var parentforum = Db.forum.SingleOrDefault(x => x.Id == forum.ParentForumId); if (parentforum != null ? parentforum.IsApproval == true : true) { veriler.Add(new SitemapItem() { loc = Url.Action("forum", "forum", new { id = forum.Id, seo = forum.Seo }, "http"), lastmod = forum.topics.Count() == 0 ? DateTime.Now : (DateTime)forum.topics.OrderByDescending(x => x.ModifyDate).First().ModifyDate, changefreq = "daily", priority = "1" }); } } foreach (var topic in Db.topic.Where(x => x.IsApproval == true && x.forum.IsApproval == true && x.forum.category.IsApproval == true)) { veriler.Add(new SitemapItem() { loc = Url.Action("topic", "forum", new { id = topic.Id, seo = topic.Seo }, "http"), lastmod = (DateTime)topic.ModifyDate, changefreq = "daily", priority = "1" }); } foreach (var user in Db.user) { veriler.Add(new SitemapItem() { loc = Url.Action("info", "account", new { username = user.UserName }, "http"), lastmod = (DateTime)user.RegistrationDate, changefreq = "daily", priority = "1" }); } Sitemap sitemap = new Sitemap(veriler); return(Content(sitemap.Result(), "text/xml")); }
public ActionResult Sitemap() { List <SitemapItem> veriler = new List <SitemapItem>(); veriler.Add(new SitemapItem() { loc = Url.Action("index", "post", null, "http"), lastmod = DateTime.Now, changefreq = "daily", priority = "1" }); veriler.Add(new SitemapItem() { loc = Url.Action("communication", "home", null, "http"), lastmod = DateTime.Now, changefreq = "daily", priority = "1" }); veriler.Add(new SitemapItem() { loc = Url.Action("index", "gallery", null, "http"), lastmod = DateTime.Now, changefreq = "daily", priority = "1" }); veriler.Add(new SitemapItem() { loc = Url.Action("index", "document", null, "http"), lastmod = DateTime.Now, changefreq = "daily", priority = "1" }); veriler.Add(new SitemapItem() { loc = Url.Action("index", "activity", null, "http"), lastmod = DateTime.Now, changefreq = "daily", priority = "1" }); veriler.Add(new SitemapItem() { loc = Url.Action("index", "factory", null, "http"), lastmod = DateTime.Now, changefreq = "daily", priority = "1" }); foreach (var page in Db.bgk_sayfa.Where(x => x.Onay == true)) { veriler.Add(new SitemapItem() { loc = Url.Action("details", "page", new { seo = page.Seo }, "http"), lastmod = DateTime.Now, changefreq = "daily", priority = "1" }); } foreach (var gallery in Db.bgk_galeri.Where(x => x.Onay == true)) { veriler.Add(new SitemapItem() { loc = Url.Action("category", "gallery", new { seo = gallery.Seo, id = gallery.Id }, "http"), lastmod = DateTime.Now, changefreq = "daily", priority = "1" }); foreach (var image in gallery.bgk_galeri_resim.Where(x => x.Onay == true)) { veriler.Add(new SitemapItem() { loc = Url.Action("images", "gallery", new { id = image.Id, seo = gallery.Seo }, "http"), lastmod = DateTime.Now, changefreq = "daily", priority = "1" }); } } foreach (var document_category in Db.bgk_dokuman_kategori.Where(x => x.Onay == true)) { veriler.Add(new SitemapItem() { loc = Url.Action("category", "document", new { seo = document_category.Seo, id = document_category.Id }, "http"), lastmod = DateTime.Now, changefreq = "daily", priority = "1" }); foreach (var document in document_category.bgk_dokuman.Where(x => x.Onay == true)) { veriler.Add(new SitemapItem() { loc = Url.Action("details", "document", new { seo = document.Seo, id = document_category.Id }, "http"), lastmod = DateTime.Now, changefreq = "daily", priority = "1" }); } } foreach (var post in Db.bgk_yazi.Where(x => x.Onay == true)) { veriler.Add(new SitemapItem() { loc = Url.Action("details", "post", new { id = post.Id, seo = post.Seo }, "http"), lastmod = DateTime.Now, changefreq = "daily", priority = "1" }); } foreach (var activity in Db.bgk_etkinlik) { veriler.Add(new SitemapItem() { loc = Url.Action("details", "activity", new { id = activity.Id, seo = activity.Adi.ConvertSeo() }, "http"), lastmod = DateTime.Now, changefreq = "daily", priority = "1" }); foreach (var speaker in activity.bgk_etkinlik_konusmaci) { veriler.Add(new SitemapItem() { loc = Url.Action("speaker", "activity", new { id = speaker.Id, seo = speaker.AdSoyad.ConvertSeo() }, "http"), lastmod = DateTime.Now, changefreq = "daily", priority = "1" }); } foreach (var officer in activity.bgk_etkinlik_gorevli) { veriler.Add(new SitemapItem() { loc = Url.Action("officer", "activity", new { id = officer.Id, seo = officer.bgk_uye.AdSoyad.ConvertSeo() }, "http"), lastmod = DateTime.Now, changefreq = "daily", priority = "1" }); } } foreach (var factory in Db.bgk_firma) { veriler.Add(new SitemapItem() { loc = Url.Action("details", "factory", new { id = factory.Id, seo = factory.Adi.ConvertSeo() }, "http"), lastmod = DateTime.Now, changefreq = "daily", priority = "1" }); } Sitemap sitemap = new Sitemap(veriler); return(Content(sitemap.Result(), "text/xml")); }