public async Task <ActionResult> HomeAsync(int pageNumber = 1) { try { if (pageNumber <= 0) { pageNumber = 1; } var awaiter = await ContentModel.GetBlogContentsAsync(this.Tenant, pageNumber).ConfigureAwait(true); var contents = awaiter?.ToList() ?? new List <Content>(); if (!contents.Any()) { return(this.View(GetLayoutPath(this.Tenant) + "404.cshtml")); } foreach (var content in contents) { content.Contents = await ContentExtensions.ParseHtmlAsync(this.Tenant, content.Contents).ConfigureAwait(false); } string theme = this.GetTheme(); string layout = ThemeConfiguration.GetBlogLayout(this.Tenant, theme).Or(ThemeConfiguration.GetLayout(this.Tenant, theme)); var configuration = await Configurations.GetDefaultConfigurationAsync(this.Tenant).ConfigureAwait(false); var model = new Blog { Contents = contents, LayoutPath = GetLayoutPath(this.Tenant), Layout = layout }; if (configuration != null) { model.Title = configuration.BlogTitle; model.Description = configuration.BlogDescription; } return(this.View(this.GetRazorView <AreaRegistration>("Frontend/Blog/Home.cshtml", this.Tenant), model)); } catch (NpgsqlException ex) { Log.Error($"An exception was encountered while trying to get blog contents. Exception: {ex}"); } return(null); }
public ActionResult Home(int pageNumber = 1) { try { if (pageNumber <= 0) { pageNumber = 1; } var contents = ContentModel.GetBlogContents(pageNumber); if (contents == null || !contents.Any()) { return(this.View(GetLayoutPath() + "404.cshtml")); } foreach (var content in contents) { content.Contents = ContentExtensions.ParseHtml(this.Tenant, content.Contents); } string theme = this.GetTheme(); string layout = ThemeConfiguration.GetBlogLayout(theme); var configuration = Configurations.GetDefaultConfiguration(); var model = new Blog { Contents = contents, LayoutPath = GetLayoutPath(), Layout = layout }; if (configuration != null) { model.Title = configuration.BlogTitle; model.Description = configuration.BlogDescription; } return(this.View(this.GetRazorView <AreaRegistration>("Blog/Home.cshtml"), model)); } catch (NpgsqlException ex) { Log.Error($"An exception was encountered while trying to get blog contents. Exception: {ex}"); } return(null); }
public ActionResult Post(string categoryAlias, string alias) { var model = ContentModel.GetContent(this.Tenant, categoryAlias, alias, true); if (model == null) { return(this.View(GetLayoutPath() + "404.cshtml")); } string path = GetLayoutPath(); string theme = this.GetTheme(); string layout = ThemeConfiguration.GetBlogLayout(theme); model.LayoutPath = path; model.Layout = layout; model.Contents = ContentExtensions.ParseHtml(this.Tenant, model.Contents); return(this.View(this.GetRazorView <AreaRegistration>("Blog/Post.cshtml"), model)); }
public async Task <ActionResult> PostAsync(string categoryAlias, string alias) { var model = await ContentModel.GetContentAsync(this.Tenant, categoryAlias, alias, true).ConfigureAwait(true); if (model == null) { return(this.View(GetLayoutPath(this.Tenant) + "404.cshtml")); } string path = GetLayoutPath(this.Tenant); string theme = this.GetTheme(); string layout = ThemeConfiguration.GetBlogLayout(this.Tenant, theme).Or(ThemeConfiguration.GetLayout(this.Tenant, theme)); model.LayoutPath = path; model.Layout = layout; model.Contents = await ContentExtensions.ParseHtmlAsync(this.Tenant, model.Contents).ConfigureAwait(true); return(this.View(this.GetRazorView <AreaRegistration>("Frontend/Blog/Post.cshtml", this.Tenant), model)); }