diff --git a/MyWebsite/MyWebsite/Controllers/GalleryController.cs b/MyWebsite/MyWebsite/Controllers/GalleryController.cs index 43a119c..2c81523 100644 --- a/MyWebsite/MyWebsite/Controllers/GalleryController.cs +++ b/MyWebsite/MyWebsite/Controllers/GalleryController.cs @@ -1,13 +1,28 @@ using Microsoft.AspNetCore.Mvc; +using MyWebsite.Models; +using Newtonsoft.Json; +using System.Net.Http; +using System.Linq; +using System.Threading.Tasks; namespace MyWebsite.Controllers { public class GalleryController : Controller { - public IActionResult Index() => - View(); - public IActionResult Details(string id) => - View(model: id); + public async Task Index() + { + ViewData["Images"] = JsonConvert.DeserializeObject(await new HttpClient().GetStringAsync($"https://{Request.Host}/Gallery.json")); + + return View(); + } + + public async Task Details(string id) + { + ViewData["CurrentImage"] = JsonConvert.DeserializeObject(await new HttpClient().GetStringAsync($"https://{Request.Host}/Gallery.json")).First(i => i.FileName == id); + + return View(); + } + } } \ No newline at end of file diff --git a/MyWebsite/MyWebsite/Models/Image.cs b/MyWebsite/MyWebsite/Models/Image.cs new file mode 100644 index 0000000..840af55 --- /dev/null +++ b/MyWebsite/MyWebsite/Models/Image.cs @@ -0,0 +1,13 @@ +using System; +using System.Globalization; + +namespace MyWebsite.Models +{ + public class Image + { + public string Title { get; set; } + public string Description { get; set; } + public DateTime CreationDate { get; set; } + public string FileName { get; set; } + } +} diff --git a/MyWebsite/MyWebsite/Views/Gallery/Details.cshtml b/MyWebsite/MyWebsite/Views/Gallery/Details.cshtml index ba721f2..c026b79 100644 --- a/MyWebsite/MyWebsite/Views/Gallery/Details.cshtml +++ b/MyWebsite/MyWebsite/Views/Gallery/Details.cshtml @@ -1,6 +1,6 @@  @{ - ViewData["Title"] = "Image overview"; + ViewData["Title"] = (ViewData["CurrentImage"] as Image).Title; }
@@ -8,11 +8,11 @@
\ No newline at end of file diff --git a/MyWebsite/MyWebsite/Views/Gallery/Index.cshtml b/MyWebsite/MyWebsite/Views/Gallery/Index.cshtml index 64c590c..06c3677 100644 --- a/MyWebsite/MyWebsite/Views/Gallery/Index.cshtml +++ b/MyWebsite/MyWebsite/Views/Gallery/Index.cshtml @@ -7,6 +7,9 @@

My arts

-
- + \ No newline at end of file diff --git a/MyWebsite/MyWebsite/Views/Shared/_Layout.cshtml b/MyWebsite/MyWebsite/Views/Shared/_Layout.cshtml index ba56ada..4d5dc82 100644 --- a/MyWebsite/MyWebsite/Views/Shared/_Layout.cshtml +++ b/MyWebsite/MyWebsite/Views/Shared/_Layout.cshtml @@ -42,7 +42,7 @@ diff --git a/MyWebsite/MyWebsite/wwwroot/Gallery.json b/MyWebsite/MyWebsite/wwwroot/Gallery.json new file mode 100644 index 0000000..d4ed8c5 --- /dev/null +++ b/MyWebsite/MyWebsite/wwwroot/Gallery.json @@ -0,0 +1,14 @@ +[ + { + "FileName": "FirstAvatar.png", + "Title": "First avatar I ever made", + "CreationDate": "2016-07-31T00:00:00", + "Description": "" + }, + { + "FileName": "VectorAvatar.svg", + "Title": "First avatar I made in vector", + "CreationDate": "2019-08-15T00:00:00", + "Description": "" + } +] \ No newline at end of file diff --git a/MyWebsite/MyWebsite/wwwroot/css/Style.css b/MyWebsite/MyWebsite/wwwroot/css/Style.css index 9099476..dc11f58 100644 --- a/MyWebsite/MyWebsite/wwwroot/css/Style.css +++ b/MyWebsite/MyWebsite/wwwroot/css/Style.css @@ -102,4 +102,19 @@ header a:hover { article a:visited { color: blue; +} + +.gallery { + margin: 50px; +} +.gallery img { + transition: .25s; + object-fit: cover; + max-width: 300px; + height: 200px; + margin: 2px; +} +.gallery img:hover { + filter: brightness(125%); + transform: scale(1.25); } \ No newline at end of file diff --git a/MyWebsite/MyWebsite/wwwroot/images/favicon.png b/MyWebsite/MyWebsite/wwwroot/images/favicon.png index 8c2b439..22345b4 100644 Binary files a/MyWebsite/MyWebsite/wwwroot/images/favicon.png and b/MyWebsite/MyWebsite/wwwroot/images/favicon.png differ