Gallery management list done
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MyWebsite.Models;
|
||||
|
||||
namespace MyWebsite.Areas.Admin.Controllers
|
||||
{
|
||||
[Area("Admin")]
|
||||
[Authorize]
|
||||
public class GalleryController : Controller
|
||||
{
|
||||
public GalleryController(DatabaseContext context) =>
|
||||
Startup.Database = context;
|
||||
|
||||
public IActionResult Index() =>
|
||||
View(Startup.Database.Gallery);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
@model IEnumerable<MyWebsite.Models.Image>
|
||||
@{
|
||||
ViewData["Title"] = "Gallery";
|
||||
}
|
||||
|
||||
<header>
|
||||
<p> <a asp-action="Index" asp-controller="Admin" asp-area="">Back to main menu</a></p>
|
||||
<h1>Gallery</h1>
|
||||
<p>
|
||||
<a asp-action="Upload" class="comment">// + Upload new</a>
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<article>
|
||||
<table>
|
||||
@foreach (Image item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
<img title="@item.Title" src="~/images/Gallery/@item.FileName" />
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<h3>@item.Title</h3>
|
||||
<span>ID: @item.Id</span> |
|
||||
<span>File name: @item.FileName</span> |
|
||||
<span>Language: @item.Language</span><br />
|
||||
<span>Creation date: @item.CreationDate.ToShortDateString()</span><br />
|
||||
<span>
|
||||
@Html.ActionLink("Edit", "Edit", new { id = item.Id }) |
|
||||
@Html.ActionLink("Delete", "Delete", new { id = item.Id })
|
||||
</span>
|
||||
<p>@Html.Raw(item.Description)</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
</article>
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="~/css/Admin.css" />
|
||||
<style type="text/css">
|
||||
img {
|
||||
height: 200px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
@@ -8,20 +9,26 @@ namespace MyWebsite.Models
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[DisplayName("ID")]
|
||||
public Guid Id { get; set; }
|
||||
[Required]
|
||||
[Column(TypeName = "varchar(100)")]
|
||||
[DisplayName("Title")]
|
||||
public string Title { get; set; }
|
||||
[Required]
|
||||
[Column(TypeName = "varchar(255)")]
|
||||
[DisplayName("Description")]
|
||||
public string Description { get; set; }
|
||||
[Required]
|
||||
[DisplayName("Created")]
|
||||
public DateTime CreationDate { get; set; }
|
||||
[Required]
|
||||
[Column(TypeName = "varchar(20)")]
|
||||
[DisplayName("File name")]
|
||||
public string FileName { get; set; }
|
||||
[Required]
|
||||
[Column(TypeName = "varchar(10)")]
|
||||
[DisplayName("Language")]
|
||||
public string Language { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<article>
|
||||
<p class="admin-menu">
|
||||
<a asp-action="FoxTube" class="comment">// FoxTube API</a><br />
|
||||
<a asp-action="Artworks" class="comment">// Artworks</a><br />
|
||||
<a asp-action="Gallery" class="comment">// Artworks</a><br />
|
||||
<a asp-action="Projects" class="comment">// Projects</a><br />
|
||||
<a asp-action="Badges" class="comment">// Badges</a><br />
|
||||
<a asp-action="Resume" class="comment">// Resume</a><br />
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
</header>
|
||||
|
||||
<article>
|
||||
@Html.Raw(Model.Content)
|
||||
@Html.Raw(Model?.Content)
|
||||
</article>
|
||||
|
||||
<partial name="~/Views/Shared/ContactsBlock.cshtml" />
|
||||
Reference in New Issue
Block a user