public PageViewModel GetPageByFiendlyUrl(string url, PageLanguages language) { Page data = _pageRepository.GetPageByFriendlyUrl(url); if (data != null) { var header = _headerTemplateRepository.GetHeaderTemplateById(data.HeaderTemplateId.Value); var footer = _footerTemplateRepository.GetFooterTemplateById(data.FooterTemplateId.Value); if (language == PageLanguages.Vietnamese) { return(new PageViewModel() { Title = data.Title, HeaderContent = header.Content, PageContent = data.Content, FooterContent = footer.Content, }); } else if (language == PageLanguages.English) { return(new PageViewModel() { Title = data.TitleEnglish, HeaderContent = header.ContentEnglish, PageContent = data.ContentEnglish, FooterContent = footer.ContentEnglish, }); } } return(new PageViewModel()); }
// GET: Pages public ActionResult Index(string friendlyUrl) { friendlyUrl = SecureUtilities.RemoveSqlInjection(friendlyUrl); PageLanguages lang = PageLanguages.Vietnamese; if (Language == "vn") { lang = PageLanguages.Vietnamese; } else if (Language == "en") { lang = PageLanguages.English; } var page = new PageViewModel(); if (friendlyUrl == "dangkynhaphoc" || friendlyUrl == "lienhe") { var headerDefault = _headerTemplateServices.GetHeaderTemplateDefault(); var footerDefault = _footerTemplateServices.GetFooterTemplateDefault(); if (Language == "vn") { page.HeaderContent = headerDefault.Content; page.FooterContent = footerDefault.Content; } else if (Language == "en") { page.HeaderContent = headerDefault.ContentEnglish; page.FooterContent = footerDefault.ContentEnglish; } ViewBag.IsSpecialPage = true; if (friendlyUrl == "dangkynhaphoc") { ViewBag.Title = "Đăng kí nhập học"; } else if (friendlyUrl == "lienhe") { ViewBag.Title = "Liên hệ"; } } else { page = _pageServices.GetPageByFiendlyUrl(friendlyUrl, lang); ViewBag.Title = page.Title; } return(View(page)); }