Changeset 6782104 for PostgreSqlDotnetCore
- Timestamp:
- 08/20/24 16:13:49 (3 months ago)
- Branches:
- main
- Children:
- 63bd770
- Parents:
- 8f8226c
- Location:
- PostgreSqlDotnetCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
PostgreSqlDotnetCore/Controllers/ErrorController.cs
r8f8226c r6782104 2 2 { 3 3 using Microsoft.AspNetCore.Http; 4 using Microsoft.AspNetCore.Identity; 4 5 using Microsoft.AspNetCore.Mvc; 6 using System.Threading.Tasks; 5 7 6 public class ErrorController : Controller8 public class ErrorController : BaseController 7 9 { 10 public ErrorController(UserManager<IdentityUser> userManager) : base(userManager) 11 { 12 13 } 8 14 // GET: ErrorController 9 public IActionResult AccessDenied()15 public async Task<IActionResult> AccessDeniedAsync() 10 16 { 17 // set if is authenticated 18 ViewBag.isAuthenticated = await getCrrentUser(); 11 19 return View(); 12 20 } 13 21 // GET: ErrorController 14 public IActionResult NotExist()22 public async Task<IActionResult> NotExistAsync() 15 23 { 24 // set if is authenticated 25 ViewBag.isAuthenticated = await getCrrentUser(); 16 26 return View(); 17 27 } -
PostgreSqlDotnetCore/Controllers/HomeController.cs
r8f8226c r6782104 4 4 using PostgreSqlDotnetCore.Models; 5 5 using System.Diagnostics; 6 using System.Web.Mvc; 6 7 7 8 namespace PostgreSqlDotnetCore.Controllers 8 9 { 9 10 10 public class HomeController : Controller11 public class HomeController : BaseController 11 12 { 12 13 private ApplicationDbContext db = new ApplicationDbContext(); … … 15 16 private readonly ILogger<HomeController> _logger; 16 17 17 public HomeController(ILogger<HomeController> logger, UserManager<IdentityUser> userManager) 18 public HomeController(ILogger<HomeController> logger, UserManager<IdentityUser> userManager) : base(userManager) 18 19 { 19 20 _logger = logger; … … 56 57 db.SaveChanges(); 57 58 } 58 59 // set if is authenticated 60 ViewBag.isAuthenticated = await getCrrentUser(); 59 61 } 60 62 63 } else 64 { 65 ViewBag.isAuthenticated = null; 61 66 } 62 67 ViewBag.ShowTopBar = true; 68 63 69 return View(); 64 70 } 65 71 66 public IActionResult Privacy()72 public async Task<IActionResult> PrivacyAsync() 67 73 { 74 75 // set if is authenticated 76 ViewBag.isAuthenticated = await getCrrentUser(); 68 77 return View(); 69 78 } 70 public IActionResult Contact()79 public async Task<IActionResult> ContactAsync() 71 80 { 81 // set if is authenticated 82 ViewBag.isAuthenticated = await getCrrentUser(); 72 83 return View(); 73 84 } -
PostgreSqlDotnetCore/Controllers/JobsController.cs
r8f8226c r6782104 12 12 public JobsController(UserManager<IdentityUser> userManager) : base(userManager) 13 13 { 14 // set if is authenticated 15 ViewBag.isAuthenticated = new UsersClass(); 14 16 } 15 17 -
PostgreSqlDotnetCore/Controllers/PetCaresController.cs
r8f8226c r6782104 32 32 // check for permission 33 33 UsersClass customerClass = await getCrrentUser(); 34 // set if is authenticated 35 ViewBag.isAuthenticated = customerClass; 34 36 if (customerClass == null) 35 37 { -
PostgreSqlDotnetCore/Controllers/PetsController.cs
r8f8226c r6782104 19 19 // check for permission 20 20 UsersClass customerClass = await getCrrentUser(); 21 22 // set if is authenticated 23 ViewBag.isAuthenticated = customerClass; 21 24 if (customerClass == null) 22 25 { … … 62 65 //} 63 66 64 public ActionResult Create()67 public async Task<ActionResult> CreateAsync() 65 68 { 66 69 70 // check for permission 71 UsersClass customerClass = await getCrrentUser(); 72 // set if is authenticated 73 ViewBag.isAuthenticated = customerClass; 67 74 return View(); 68 75 } … … 78 85 if (!isAuthenticated) 79 86 { 87 // set if is authenticated 88 ViewBag.isAuthenticated = null; 80 89 return RedirectToAction("AccessDenied", "Error"); 81 90 } 91 ViewBag.isAuthenticated = new UsersClass(); 92 82 93 if (ModelState.IsValid) 83 94 { 84 // peClass.dateofbirthday = DateTime.SpecifyKind(peClass.dateofbirthday, DateTimeKind.Utc); 95 // set if is authenticated 96 ViewBag.isAuthenticated = new UsersClass(); 97 // peClass.dateofbirthday = DateTime.SpecifyKind(peClass.dateofbirthday, DateTimeKind.Utc); 85 98 var user = await _userManager.GetUserAsync(User); 86 99 var customerClass = db.CustomerObj.SingleOrDefault(x => x.email == user.Email); … … 121 134 if (!isAuthenticated) 122 135 { 136 // set if is authenticated 137 ViewBag.isAuthenticated = null; 123 138 return RedirectToAction("AccessDenied", "Error"); 124 139 } 140 141 // set if is authenticated 142 ViewBag.isAuthenticated = new UsersClass(); 143 125 144 126 145 if (ModelState.IsValid) -
PostgreSqlDotnetCore/Controllers/ProductsController.cs
r8f8226c r6782104 16 16 public ProductsController(UserManager<IdentityUser> userManager) : base(userManager) 17 17 { 18 // set if is authenticated 19 ViewBag.isAuthenticated = new UsersClass(); 18 20 } 19 21 … … 28 30 public ActionResult Index(string? searchString) 29 31 { 32 // set if is authenticated 33 ViewBag.isAuthenticated = new UsersClass(); 30 34 if (!String.IsNullOrEmpty(searchString)) 31 35 { … … 67 71 // check for permission 68 72 UsersClass customerClass = await checkAuthorizationAsync(); 73 // set if is authenticated 74 ViewBag.isAuthenticated = await getCrrentUser(); 75 69 76 if (customerClass == null) 70 77 { … … 100 107 } 101 108 102 103 104 105 106 107 108 109 110 111 112 109 // GET: Customer/Edit/5 113 110 public async Task<ActionResult> EditAsync(int? id) … … 118 115 } 119 116 UsersClass customerClass = await checkAuthorizationAsync(); 117 // set if is authenticated 118 ViewBag.isAuthenticated = await getCrrentUser(); 119 120 120 if (customerClass == null) 121 121 { … … 154 154 } 155 155 UsersClass customerClass = await checkAuthorizationAsync(); 156 // set if is authenticated 157 ViewBag.isAuthenticated = await getCrrentUser(); 158 156 159 if (customerClass == null) 157 160 { -
PostgreSqlDotnetCore/Controllers/VetCenterController.cs
r8f8226c r6782104 12 12 public VetCenterController(UserManager<IdentityUser> userManager) : base(userManager) 13 13 { 14 15 // set if is authenticated 16 ViewBag.isAuthenticated = new UsersClass(); 14 17 } 15 18 -
PostgreSqlDotnetCore/Views/Shared/_Layout.cshtml
r8f8226c r6782104 13 13 </head> 14 14 <body> 15 <h1>@(ViewBag.isAuthenticated == null ? "krij" : "prikazi")</h1> 15 16 <header> 16 17 <nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3"> … … 26 27 <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a> 27 28 </li> 28 <li class="nav-item"> 29 <a class="nav-link text-dark" asp-area="" asp-controller="Pets" asp-action="Index">Pets</a> 30 </li> 29 @{ 30 if (ViewBag.isAuthenticated != null) 31 { 32 <li class="nav-item"> 33 <a class="nav-link text-dark" asp-area="" asp-controller="Pets" asp-action="Index">Pets</a> 34 </li> 35 } 36 } 31 37 <li class="nav-item"> 32 38 <a class="nav-link text-dark" asp-area="" asp-controller="Products" asp-action="Index">Products</a> 33 39 </li> 34 <li class="nav-item"> 35 <a class="nav-link text-dark" asp-area="" asp-controller="PetCares" asp-action="Index">Pet Cares</a> 36 </li> 37 <li class="nav-item"> 38 <a class="nav-link text-dark" asp-area="" asp-controller="Customer" asp-action="Index">Manage Customers</a> 39 </li> 40 <li class="nav-item"> 41 <a class="nav-link text-dark" asp-area="" asp-controller="City" asp-action="Index">Manage Cities</a> 42 </li> 43 <li class="nav-item"> 44 <a class="nav-link text-dark" asp-area="" asp-controller="Blog" asp-action="Index">BlogPost</a> 45 </li> 40 @{ 41 if (ViewBag.isAuthenticated != null) 42 { 43 <li class="nav-item"> 44 <a class="nav-link text-dark" asp-area="" asp-controller="PetCares" asp-action="Index">Pet Cares</a> 45 </li> 46 <li class="nav-item"> 47 <a class="nav-link text-dark" asp-area="" asp-controller="Customer" asp-action="Index">Manage Customers</a> 48 </li> 49 <li class="nav-item"> 50 <a class="nav-link text-dark" asp-area="" asp-controller="City" asp-action="Index">Manage Cities</a> 51 </li> 52 <li class="nav-item"> 53 <a class="nav-link text-dark" asp-area="" asp-controller="Blog" asp-action="Index">BlogPost</a> 54 </li> 55 } 56 } 46 57 <li class="nav-item"> 47 58 <a class="nav-link text-dark" asp-area="" asp-controller="VetCenter" asp-action="Index">VetCenters</a>
Note:
See TracChangeset
for help on using the changeset viewer.