//private string defaultChildrensSortingCriteria = "price"; public PageHelper(HttpContext httpContext, string pageCode, string lang) { try { pContext = httpContext.RequestServices.GetService(typeof(PageContext)) as PageContext; PageEntity p = pContext.GetEntity(pageCode); if (p.AliasOf != null) { PageEntity truePage = pContext.GetEntity(p.AliasOf); CaptionAndContentFilling(lang, truePage); string redirectUrl = string.Format("/{0}/{1}", p.AliasOf, lang); httpContext.Response.Redirect(redirectUrl, true); } else { CaptionAndContentFilling(lang, p); if (p.IsContainer != null) { if (p.IsContainer == true) { string childrensContent = GetChildrensContent(p, lang); content = content.Replace("~1", childrensContent); } } } } catch (NullReferenceException ne) { caption = ne.Message + " Some of the parameters for PageHelper constructor have had empty value!"; } catch (Exception ex) { //for debugging caption = ex.Message; } }
private void CaptionAndContentFilling(string lang, PageEntity p) { string buf = string.Empty; switch (lang) { case "UA": if (p.CaptionUA != null) { caption = p.CaptionUA; } buf = p.ContentUA; break; case "RU": if (p.ContentRU != null) { caption = p.CaptionRU; } buf = p.ContentRU; break; case "EN": if (p.CaptionEN != null) { caption = p.CaptionEN; } buf = p.ContentEN; break; default: throw new NullReferenceException("Language == null!"); } buf = buf.Replace("~2", p.Price.ToString()); content = buf; }