Skip to content

Commit

Permalink
Section 12 - Authorization
Browse files Browse the repository at this point in the history
  • Loading branch information
bhrugen committed Sep 27, 2021
1 parent 3d867f1 commit 48b89b1
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 17 deletions.
3 changes: 3 additions & 0 deletions BulkyBookWeb/Areas/Admin/Controllers/CategoryController.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
using BulkyBook.DataAccess;
using BulkyBook.DataAccess.Repository.IRepository;
using BulkyBook.Models;
using BulkyBook.Utility;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Linq;

namespace BulkyBookWeb.Controllers;
[Area("Admin")]
[Authorize(Roles = SD.Role_Admin)]
public class CategoryController : Controller
{
private readonly IUnitOfWork _unitOfWork;
Expand Down
3 changes: 3 additions & 0 deletions BulkyBookWeb/Areas/Admin/Controllers/CompanyController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using BulkyBook.DataAccess.Repository.IRepository;
using BulkyBook.Models;
using BulkyBook.Models.ViewModels;
using BulkyBook.Utility;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
Expand All @@ -13,6 +15,7 @@

namespace BulkyBookWeb.Controllers;
[Area("Admin")]
[Authorize(Roles = SD.Role_Admin)]
public class CompanyController : Controller
{
private readonly IUnitOfWork _unitOfWork;
Expand Down
3 changes: 3 additions & 0 deletions BulkyBookWeb/Areas/Admin/Controllers/CoverTypeController.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
using BulkyBook.DataAccess;
using BulkyBook.DataAccess.Repository.IRepository;
using BulkyBook.Models;
using BulkyBook.Utility;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Linq;

namespace BulkyBookWeb.Controllers;
[Area("Admin")]
[Authorize(Roles = SD.Role_Admin)]
public class CoverTypeController : Controller
{
private readonly IUnitOfWork _unitOfWork;
Expand Down
3 changes: 3 additions & 0 deletions BulkyBookWeb/Areas/Admin/Controllers/ProductController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using BulkyBook.DataAccess.Repository.IRepository;
using BulkyBook.Models;
using BulkyBook.Models.ViewModels;
using BulkyBook.Utility;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
Expand All @@ -13,6 +15,7 @@

namespace BulkyBookWeb.Controllers;
[Area("Admin")]
[Authorize(Roles = SD.Role_Admin)]
public class ProductController : Controller
{
private readonly IUnitOfWork _unitOfWork;
Expand Down
12 changes: 6 additions & 6 deletions BulkyBookWeb/Areas/Admin/Views/Order/Details.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,11 @@
</div>
</li>
</ul>

@if (Model.OrderHeader.PaymentStatus == SD.PaymentStatusDelayedPayment &&
Model.OrderHeader.OrderStatus == SD.StatusShipped)
{
<input type="submit" class="btn btn-success form-control my-1" value="Pay Now" />
}
@if (User.IsInRole(SD.Role_Admin) || User.IsInRole(SD.Role_Employee))
{
if (Model.OrderHeader.OrderStatus == SD.StatusApproved)
Expand All @@ -245,11 +249,7 @@
<input type="submit" onclick="return validateInput()"
asp-action="ShipOrder" class="btn btn-primary form-control my-1" value="Ship Order" />
}
@if (Model.OrderHeader.PaymentStatus == SD.PaymentStatusDelayedPayment &&
Model.OrderHeader.OrderStatus == SD.StatusShipped)
{
<input type="submit" class="btn btn-success form-control my-1" value="Pay Now" />
}

@if (Model.OrderHeader.OrderStatus != SD.StatusRefunded &&
Model.OrderHeader.OrderStatus != SD.StatusCancelled &&
Model.OrderHeader.OrderStatus!=SD.StatusShipped)
Expand Down
26 changes: 15 additions & 11 deletions BulkyBookWeb/Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<!DOCTYPE html>
@using BulkyBook.Utility
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
Expand All @@ -24,16 +25,19 @@

<a class="nav-link " asp-area="Customer" asp-controller="Home" asp-action="Index">Home</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Content Managment</a>
<div class="dropdown-menu">
<a class="dropdown-item" asp-area="Admin" asp-controller="Category" asp-action="Index">Category</a>
<a class="dropdown-item" asp-area="Admin" asp-controller="CoverType" asp-action="Index">Cover Type</a>
<a class="dropdown-item" asp-area="Admin" asp-controller="Product" asp-action="Index">Product</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" asp-area="Admin" asp-controller="Company" asp-action="Index">Company</a>
</div>
</li>
@if (User.IsInRole(SD.Role_Admin))
{
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Content Managment</a>
<div class="dropdown-menu">
<a class="dropdown-item" asp-area="Admin" asp-controller="Category" asp-action="Index">Category</a>
<a class="dropdown-item" asp-area="Admin" asp-controller="CoverType" asp-action="Index">Cover Type</a>
<a class="dropdown-item" asp-area="Admin" asp-controller="Product" asp-action="Index">Product</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" asp-area="Admin" asp-controller="Company" asp-action="Index">Company</a>
</div>
</li>
}
<li class="nav-item">
<a class=nav-link asp-area="Admin" asp-controller="Order" asp-action="Index">
Manage Order
Expand Down

0 comments on commit 48b89b1

Please sign in to comment.