mirror of
https://github.com/yawaflua/yaflay.ru.git
synced 2025-12-11 16:16:26 +02:00
Add caching all data from backend and change getting readme data from page(Index.cshtml) to api(HomeController.cs) with cache readme file
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
@page "{id?}"
|
||||
@model BlogModel
|
||||
@using yaflay.ru.Models.Tables
|
||||
@using Newtonsoft.Json
|
||||
@{
|
||||
string path = $"{this.Request.Scheme}://{this.Request.Host}";
|
||||
if (Model.Id != 0)
|
||||
{
|
||||
|
||||
Blogs? Post = Startup.dbContext.Blogs.FirstOrDefault(k => k.Id == Model.Id);
|
||||
//Blogs? Post = Startup.dbContext.Blogs.FirstOrDefault(k => k.Id == Model.Id);
|
||||
var request = await Startup.client.GetAsync(path + "/api/Blog/" + Model.Id);
|
||||
Blogs? Post = JsonConvert.DeserializeObject<Blogs>(request.Content.ReadAsStringAsync().Result);
|
||||
if (Post == null)
|
||||
{
|
||||
ViewData["Title"] = "Blogs";
|
||||
@@ -66,7 +69,8 @@
|
||||
else
|
||||
{
|
||||
ViewData["Title"] = "Blog";
|
||||
var allBlogs = Startup.dbContext.Blogs.ToArray();
|
||||
var request = await Startup.client.GetAsync(path + "/api/Blog/");
|
||||
Blogs[]? allBlogs = JsonConvert.DeserializeObject<Blogs[]>(request.Content.ReadAsStringAsync().Result);
|
||||
if (allBlogs.Length == 0)
|
||||
{
|
||||
<p>
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
<h3 align="left" class="readme" >README.md</h3>
|
||||
|
||||
@{
|
||||
string Github_readme = Startup.client.GetStringAsync(Startup.readmeFile).Result;
|
||||
string path = $"{this.Request.Scheme}://{this.Request.Host}";
|
||||
string Github_readme = Startup.client.GetStringAsync($"{path}/api/Index").Result;
|
||||
<div class="text"> @Html.Raw(Github_readme) </div>
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user