Refactoring - split data, logic and model layers; custom network exception
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
@page
|
||||
@using StudentHouseDashboard.Models;
|
||||
@using Models;
|
||||
@using System.Globalization
|
||||
@model WebApp.Pages.AnnouncementModel
|
||||
@{
|
||||
|
@@ -1,8 +1,8 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using StudentHouseDashboard.Managers;
|
||||
using StudentHouseDashboard.Models;
|
||||
using Logic;
|
||||
using Models;
|
||||
|
||||
namespace WebApp.Pages
|
||||
{
|
||||
|
@@ -1,5 +1,5 @@
|
||||
@page
|
||||
@using StudentHouseDashboard.Models;
|
||||
@using Models;
|
||||
@using System.Security.Claims;
|
||||
@model WebApp.Pages.AnnouncementsModel
|
||||
@{
|
||||
|
@@ -1,8 +1,8 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using StudentHouseDashboard.Managers;
|
||||
using StudentHouseDashboard.Models;
|
||||
using Logic;
|
||||
using Models;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace WebApp.Pages
|
||||
|
@@ -1,25 +0,0 @@
|
||||
@page
|
||||
@model WebApp.Pages.ContactModel
|
||||
@{
|
||||
ViewData["Title"] = "Contact";
|
||||
}
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
|
||||
@if (ViewData["confirm"] != null)
|
||||
{
|
||||
<div class="alert alert-primary" role="alert">
|
||||
@ViewData["confirm"]
|
||||
</div>
|
||||
}
|
||||
|
||||
<form method="post">
|
||||
<div class="mb-3">
|
||||
<label asp-for="Contact.Name" class="form-label">Name: </label>
|
||||
<input asp-for="Contact.Name" class="form-control" />
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label asp-for="Contact.Email" class="form-label">Email</label>
|
||||
<input asp-for="Contact.Email" class="form-control" />
|
||||
</div>
|
||||
<input type="submit" value="Submit" class="btn btn-primary" />
|
||||
</form>
|
@@ -1,19 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace WebApp.Pages
|
||||
{
|
||||
public class ContactModel : PageModel
|
||||
{
|
||||
[BindProperty]
|
||||
public Contact Contact { get; set; }
|
||||
public void OnGet()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnPost()
|
||||
{
|
||||
ViewData["confirm"] = $"Thank you for contacting us, {Contact.Name}! We promise to return a response in a timely manner to the following e-mail address: {Contact.Email}";
|
||||
}
|
||||
}
|
||||
}
|
@@ -2,8 +2,8 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using StudentHouseDashboard.Models;
|
||||
using StudentHouseDashboard.Managers;
|
||||
using Models;
|
||||
using Logic;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace WebApp.Pages
|
||||
|
6
StudentHouseDashboard/WebApp/Pages/Logout.cshtml
Normal file
6
StudentHouseDashboard/WebApp/Pages/Logout.cshtml
Normal file
@@ -0,0 +1,6 @@
|
||||
@page
|
||||
@model WebApp.Pages.LogoutModel
|
||||
@{
|
||||
}
|
||||
<h1>Logout</h1>
|
||||
<p>You should be redirected to the <a href="/">homepage</a></p>
|
15
StudentHouseDashboard/WebApp/Pages/Logout.cshtml.cs
Normal file
15
StudentHouseDashboard/WebApp/Pages/Logout.cshtml.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace WebApp.Pages
|
||||
{
|
||||
public class LogoutModel : PageModel
|
||||
{
|
||||
public IActionResult OnGet()
|
||||
{
|
||||
HttpContext.SignOutAsync();
|
||||
return RedirectToPage("Index");
|
||||
}
|
||||
}
|
||||
}
|
@@ -5,4 +5,8 @@
|
||||
}
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
|
||||
<p>No data is currently collected.</p>
|
||||
<h2>Collected personal data</h2>
|
||||
<li>
|
||||
<ul>Password (hashed and salted)</ul>
|
||||
<ul>User-generated content (posts)</ul>
|
||||
</li>
|
||||
|
@@ -1,5 +1,5 @@
|
||||
@page
|
||||
@using StudentHouseDashboard.Models;
|
||||
@using Models;
|
||||
@model WebApp.Pages.RegisterModel
|
||||
@{
|
||||
ViewData["Title"] = "Register";
|
||||
|
@@ -1,7 +1,7 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using StudentHouseDashboard.Managers;
|
||||
using StudentHouseDashboard.Models;
|
||||
using Logic;
|
||||
using Models;
|
||||
|
||||
namespace WebApp.Pages
|
||||
{
|
||||
|
@@ -22,15 +22,30 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-page="/Index">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-page="/Announcements">Announcements</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-page="/Login">Login</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-page="/Register">Register</a>
|
||||
</li>
|
||||
@if (!User.Identity.IsAuthenticated)
|
||||
{
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-page="/Login">Login</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-page="/Register">Register</a>
|
||||
</li>
|
||||
}
|
||||
else
|
||||
{
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-page="/Announcements">Announcements</a>
|
||||
</li>
|
||||
if (User.IsInRole("ADMIN") || User.IsInRole("MANAGER"))
|
||||
{
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-page="/Register">Create user</a>
|
||||
</li>
|
||||
}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-page="/Logout">Logout</a>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user