Changeset 6782104 for PostgreSqlDotnetCore/Controllers
- Timestamp:
- 08/20/24 16:13:49 (3 months ago)
- Branches:
- main
- Children:
- 63bd770
- Parents:
- 8f8226c
- Location:
- PostgreSqlDotnetCore/Controllers
- Files:
-
- 7 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
Note:
See TracChangeset
for help on using the changeset viewer.