1
0

Updated gallery and projects controllers

This commit is contained in:
Michael Gordeev
2019-11-13 15:28:15 +03:00
parent 21d4201c4b
commit 0128a52410
6 changed files with 12 additions and 15 deletions
+3 -6
View File
@@ -12,16 +12,13 @@ namespace MyWebsite.Controllers
[HttpGet("Arts")] [HttpGet("Arts")]
public async Task<IActionResult> Index() public async Task<IActionResult> Index()
{ {
ViewData["Images"] = JsonConvert.DeserializeObject<Image[]>(await new HttpClient().GetStringAsync($"{Request.Scheme}://{Request.Host}/Gallery.json")); return View(JsonConvert.DeserializeObject<Image[]>(await new HttpClient().GetStringAsync($"{Request.Scheme}://{Request.Host}/Gallery.json")));
return View();
} }
[HttpGet("Image")]
public async Task<IActionResult> Details(string id) public async Task<IActionResult> Details(string id)
{ {
ViewData["CurrentImage"] = JsonConvert.DeserializeObject<Image[]>(await new HttpClient().GetStringAsync($"https://{Request.Host}/Gallery.json")).First(i => i.FileName == id); return View(JsonConvert.DeserializeObject<Image[]>(await new HttpClient().GetStringAsync($"https://{Request.Host}/Gallery.json")).First(i => i.FileName == id));
return View();
} }
} }
+3 -3
View File
@@ -1,7 +1,7 @@
@{ @{
ViewData["Title"] = (ViewData["CurrentImage"] as Image).Title; ViewData["Title"] = Model.Title;
Image image = ViewData["CurrentImage"] as Image; Image image = Model;
} }
<header> <header>
@@ -15,7 +15,7 @@
<h1>@image.Title</h1> <h1>@image.Title</h1>
<span>Creation date: @image.CreationDate.ToShortDateString()</span> <span>Creation date: @image.CreationDate.ToShortDateString()</span>
<p> <p>
@foreach(string line in image.Description.Split("<br />")) @foreach(string line in image.Description.Split("\n"))
{ {
@line<br /> @line<br />
} }
+1 -1
View File
@@ -8,7 +8,7 @@
</header> </header>
<article class="info-block gallery"> <article class="info-block gallery">
@foreach (Image image in ViewData["Images"] as Image[]) @foreach (Image image in Model)
{ {
<a asp-action="Details" asp-route-id="@image.FileName"><img title="@image.Title" src="~/images/Gallery/@image.FileName"/></a> <a asp-action="Details" asp-route-id="@image.FileName"><img title="@image.Title" src="~/images/Gallery/@image.FileName"/></a>
} }
+1 -1
View File
@@ -17,7 +17,7 @@
<div> <div>
<h1>@p.Title</h1> <h1>@p.Title</h1>
<p class="description"> <p class="description">
@foreach(string line in p.Description.Split("<br />")) @foreach(string line in p.Description.Split("\n"))
{ {
@line<br /> @line<br />
} }
+1 -1
View File
@@ -9,6 +9,6 @@
"FileName": "Cakeday.png", "FileName": "Cakeday.png",
"Title": "Happy cakeday to me!", "Title": "Happy cakeday to me!",
"CreationDate": "2019-11-06", "CreationDate": "2019-11-06",
"Description": "A little doodle I made for my fist year anniversary on Reddit<br />Tools: Adobe Photoshop CC 2019" "Description": "A little doodle I made for my fist year anniversary on Reddit\nTools: Adobe Photoshop CC 2019"
} }
] ]
+3 -3
View File
@@ -1,7 +1,7 @@
[ [
{ {
"Title": "FoxTube", "Title": "FoxTube",
"Description": "This is my first big project. And the first one published in Microsoft Store.<br />This is a Windows client application for YouTube", "Description": "This is my first big project. And the first one published in Microsoft Store.\nThis is a Windows client application for YouTube",
"ImageName": "FoxTube.png", "ImageName": "FoxTube.png",
"Link": "//foxtube.xfox111.net", "Link": "//foxtube.xfox111.net",
"LinkCaption": "Learn more...", "LinkCaption": "Learn more...",
@@ -27,7 +27,7 @@
}, },
{ {
"Title": "MotionDecoder", "Title": "MotionDecoder",
"Description": "This project is used to analyze videos from security cameras and shows short clips which contain detected motions.<br />I made this projects during scientific projects competition in big data division.", "Description": "This project is used to analyze videos from security cameras and shows short clips which contain detected motions.\nI made this projects during scientific projects competition in big data division.",
"ImageName": "MotionDecoder.png", "ImageName": "MotionDecoder.png",
"Link": "//github.com/XFox111/motiondecoder", "Link": "//github.com/XFox111/motiondecoder",
"LinkCaption": "View on GitHub", "LinkCaption": "View on GitHub",
@@ -77,7 +77,7 @@
}, },
{ {
"Title": "GZipCompression", "Title": "GZipCompression",
"Description": "Console program which splits files on 1MB blocks and compresses them in multi-thread.<br />I made this program as intro challange in Veeam Software", "Description": "Console program which splits files on 1MB blocks and compresses them in multi-thread.\nI made this program as intro challange in Veeam Software",
"ImageName": "", "ImageName": "",
"Link": "https://github.com/XFox111/gzipcompression", "Link": "https://github.com/XFox111/gzipcompression",
"LinkCaption": "View on GitHub", "LinkCaption": "View on GitHub",