From d66b874de1eda3ea6976171b770785d4181a1e45 Mon Sep 17 00:00:00 2001 From: Michael Gordeev Date: Thu, 12 Dec 2019 18:06:33 +0300 Subject: [PATCH] Updated admin panel --- .../Admin/Controllers/ContactsController.cs | 2 + .../Areas/Admin/Views/Contacts/Edit.cshtml | 45 ----------------- .../Areas/Admin/Views/Contacts/Index.cshtml | 50 +++++++++++++------ MyWebsite/MyWebsite/MyWebsite.csproj | 8 ++- MyWebsite/MyWebsite/Views/Admin/Index.cshtml | 1 + .../MyWebsite/Views/Shared/_Layout.cshtml | 10 ++-- 6 files changed, 51 insertions(+), 65 deletions(-) delete mode 100644 MyWebsite/MyWebsite/Areas/Admin/Views/Contacts/Edit.cshtml diff --git a/MyWebsite/MyWebsite/Areas/Admin/Controllers/ContactsController.cs b/MyWebsite/MyWebsite/Areas/Admin/Controllers/ContactsController.cs index 459e459..82a44e2 100644 --- a/MyWebsite/MyWebsite/Areas/Admin/Controllers/ContactsController.cs +++ b/MyWebsite/MyWebsite/Areas/Admin/Controllers/ContactsController.cs @@ -2,12 +2,14 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using MyWebsite.Models; namespace MyWebsite.Areas.Admin.Controllers { [Area("Admin")] + [Authorize] public class ContactsController : Controller { public ContactsController(DatabaseContext context) => diff --git a/MyWebsite/MyWebsite/Areas/Admin/Views/Contacts/Edit.cshtml b/MyWebsite/MyWebsite/Areas/Admin/Views/Contacts/Edit.cshtml deleted file mode 100644 index e9630a0..0000000 --- a/MyWebsite/MyWebsite/Areas/Admin/Views/Contacts/Edit.cshtml +++ /dev/null @@ -1,45 +0,0 @@ -@using MyWebsite.Models; -@model Link; -@{ - ViewData["Title"] = "Edit link"; -} - -
-

Edit contact link

-

Back to the list

-
- -
-
-
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - -
-
- -
-
-
- - \ No newline at end of file diff --git a/MyWebsite/MyWebsite/Areas/Admin/Views/Contacts/Index.cshtml b/MyWebsite/MyWebsite/Areas/Admin/Views/Contacts/Index.cshtml index 1714b5f..1632ec9 100644 --- a/MyWebsite/MyWebsite/Areas/Admin/Views/Contacts/Index.cshtml +++ b/MyWebsite/MyWebsite/Areas/Admin/Views/Contacts/Index.cshtml @@ -1,32 +1,51 @@ @model IEnumerable @{ - ViewData["Title"] = "Contacts - Admin panel"; + ViewData["Title"] = "Index"; }
-

Contact links list

-

Back to admin panel

+

Index

+

+ // + Create New +

-

- // + Create New -

- - - - - + + + + + + + + - @foreach (var item in Model.OrderByDescending(i => i.CanContactMe)) + @foreach (var item in Model) { + @@ -43,8 +62,11 @@ @Html.DisplayFor(modelItem => item.CanContactMe) + } diff --git a/MyWebsite/MyWebsite/MyWebsite.csproj b/MyWebsite/MyWebsite/MyWebsite.csproj index 4421eac..65bebe1 100644 --- a/MyWebsite/MyWebsite/MyWebsite.csproj +++ b/MyWebsite/MyWebsite/MyWebsite.csproj @@ -4,6 +4,13 @@ netcoreapp3.1 + + + + + + + @@ -18,7 +25,6 @@ - diff --git a/MyWebsite/MyWebsite/Views/Admin/Index.cshtml b/MyWebsite/MyWebsite/Views/Admin/Index.cshtml index 0726ec4..bfcfe36 100644 --- a/MyWebsite/MyWebsite/Views/Admin/Index.cshtml +++ b/MyWebsite/MyWebsite/Views/Admin/Index.cshtml @@ -9,6 +9,7 @@
NameTitleUsernameURLContact link + @Html.DisplayNameFor(model => model.Id) + + @Html.DisplayNameFor(model => model.Name) + + @Html.DisplayNameFor(model => model.Title) + + @Html.DisplayNameFor(model => model.Username) + + @Html.DisplayNameFor(model => model.Url) + + @Html.DisplayNameFor(model => model.CanContactMe) + + @Html.DisplayNameFor(model => model.DisplayInFooter) +
+ @Html.DisplayFor(modelItem => item.Id) + @Html.DisplayFor(modelItem => item.Name) - @Html.ActionLink("Edit", "Edit", new { id = item.Name }) | - @Html.ActionLink("Delete", "Delete", new { id = item.Name }) + @Html.DisplayFor(modelItem => item.DisplayInFooter) + + @Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) | + @Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })