Page numbers fixed, Register with roles not shown to guests
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
@@ -7,8 +8,11 @@ namespace StudentHouseDashboard.Models
|
|||||||
{
|
{
|
||||||
public enum UserRole
|
public enum UserRole
|
||||||
{
|
{
|
||||||
|
[Display(Name = "Tenant")]
|
||||||
TENANT,
|
TENANT,
|
||||||
|
[Display(Name = "Manager")]
|
||||||
MANAGER,
|
MANAGER,
|
||||||
|
[Display(Name = "Administrator")]
|
||||||
ADMIN
|
ADMIN
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -33,7 +33,7 @@
|
|||||||
@if (currentPage <= 1)
|
@if (currentPage <= 1)
|
||||||
{
|
{
|
||||||
@: <li class="page-item disabled">
|
@: <li class="page-item disabled">
|
||||||
@: <a class="page-link" href="./Announcements?p=@(currentPage - 1)" tabindex="-1">Previous</a>
|
@: <a class="page-link" tabindex="-1">Previous</a>
|
||||||
@: </li>
|
@: </li>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -44,16 +44,18 @@
|
|||||||
@: <li class="page-item"><a class="page-link" href="./Announcements?p=@(currentPage - 1)">@(currentPage - 1)</a></li>
|
@: <li class="page-item"><a class="page-link" href="./Announcements?p=@(currentPage - 1)">@(currentPage - 1)</a></li>
|
||||||
}
|
}
|
||||||
<li class="page-item"><a class="page-link">@currentPage</a>
|
<li class="page-item"><a class="page-link">@currentPage</a>
|
||||||
@if (announcements.Count == 0)
|
@if (announcements.Count == 0 || announcements.Count < Convert.ToInt32(ViewData["count"]))
|
||||||
{
|
{
|
||||||
@: <li class="page-item disabled">
|
@: <li class="page-item disabled">
|
||||||
|
@: <a class="page-link">Next</a>
|
||||||
|
@: </li>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@: <li class="page-item"><a class="page-link" href="./Announcements?p=@(currentPage + 1)">@(currentPage + 1)</a></li>
|
@: <li class="page-item"><a class="page-link" href="./Announcements?p=@(currentPage + 1)">@(currentPage + 1)</a></li>
|
||||||
@: <li class="page-item">
|
@: <li class="page-item">
|
||||||
|
@: <a class="page-link" href="./Announcements?p=@(currentPage + 1)">Next</a>
|
||||||
|
@: </li>
|
||||||
}
|
}
|
||||||
<a class="page-link" href="./Announcements?p=@(currentPage + 1)">Next</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
@@ -18,8 +18,13 @@ namespace WebApp.Pages
|
|||||||
{
|
{
|
||||||
p = 1;
|
p = 1;
|
||||||
}
|
}
|
||||||
|
if (c == null || c < 1)
|
||||||
|
{
|
||||||
|
c = 10;
|
||||||
|
}
|
||||||
ViewData.Add("announcements", AnnouncementManager.GetAnnouncementsByPage(p - 1, c));
|
ViewData.Add("announcements", AnnouncementManager.GetAnnouncementsByPage(p - 1, c));
|
||||||
ViewData.Add("page", p);
|
ViewData.Add("page", p);
|
||||||
|
ViewData.Add("count", c);
|
||||||
ViewData.Add("allCount", AnnouncementManager.GetAllAnnouncements().Count());
|
ViewData.Add("allCount", AnnouncementManager.GetAllAnnouncements().Count());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
@page
|
@page
|
||||||
|
@using StudentHouseDashboard.Models;
|
||||||
@model WebApp.Pages.RegisterModel
|
@model WebApp.Pages.RegisterModel
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Register";
|
ViewData["Title"] = "Register";
|
||||||
@@ -14,10 +15,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<div class="mb-3">
|
@if (HttpContext.User.IsInRole("ADMIN") || HttpContext.User.IsInRole("MANAGER"))
|
||||||
<label asp-for="MyUser.Role" class="form-label">Role: </label>
|
{
|
||||||
<input asp-for="MyUser.Role" class="form-control" />
|
@: <div class="mb-3">
|
||||||
</div>
|
<label asp-for="MyUser.Role" class="form-label">Role: </label>
|
||||||
|
<select asp-for="MyUser.Role" asp-items="Html.GetEnumSelectList<UserRole>()">
|
||||||
|
<option>Please select a role</option>
|
||||||
|
</select>
|
||||||
|
@: </div>
|
||||||
|
}
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label asp-for="MyUser.Name" class="form-label">Name: </label>
|
<label asp-for="MyUser.Name" class="form-label">Name: </label>
|
||||||
<input asp-for="MyUser.Name" class="form-control" />
|
<input asp-for="MyUser.Name" class="form-control" />
|
||||||
|
Reference in New Issue
Block a user