Changeset 118e414 for PostgreSqlDotnetCore/Controllers/CityController.cs
- Timestamp:
- 08/23/24 15:40:14 (2 months ago)
- Branches:
- main
- Children:
- e9bb9d1
- Parents:
- 72b1da2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
PostgreSqlDotnetCore/Controllers/CityController.cs
r72b1da2 r118e414 16 16 // GET: Customer 17 17 public async Task<ActionResult> IndexAsync() 18 { 19 // check for permission 20 UsersClass customerClass = await checkAuthorizationAsync(); 18 { 19 // check for permission 20 UsersClass customerClass = await checkAuthorizationAsync(); 21 ViewBag.isAuthenticated = User.Identity.IsAuthenticated; 21 22 22 23 if (customerClass == null) 24 { 25 return RedirectToAction("AccessDenied", "Error"); 26 } 23 if (customerClass == null) 24 { 25 return RedirectToAction("AccessDenied", "Error"); 26 } 27 27 28 28 var citiess = await db.CitiesObj.ToListAsync(); 29 // проба на 23.08 30 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 29 31 30 32 return View(citiess); 31 33 } 32 34 33 35 34 36 … … 50 52 51 53 // GET: Customer/Details/5 52 public ActionResult Details(int? id) 54 //public ActionResult Details(int? id) 55 public async Task<ActionResult> Details(int? id) 53 56 { 54 57 if (id == null) … … 57 60 } 58 61 CitiesClass cityClass = db.CitiesObj.Find(id); 62 UsersClass customerClass = await getCrrentUser(); 63 ViewBag.isAuthenticated = customerClass; 59 64 if (cityClass == null) 60 65 { 61 66 return RedirectToAction("NotExist", "Error"); 62 67 } 68 // no access for standard user 69 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 70 63 71 return View(cityClass); 64 72 } … … 70 78 //} 71 79 72 public ActionResult Create() 80 //public ActionResult Create() 81 public async Task<ActionResult> CreateAsync() 73 82 { 74 83 UsersClass customerClass = await getCrrentUser(); 84 // set if is authenticated 85 ViewBag.isAuthenticated = customerClass; 86 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 75 87 return View(); 76 88 } … … 83 95 public ActionResult Create([Bind(include: "id,name")] CitiesClass cityClass) 84 96 { 97 85 98 if (ModelState.IsValid) 86 99 { … … 94 107 95 108 // GET: Customer/Edit/5 96 public ActionResult Edit(int? id) 109 // public ActionResult Edit(int? id) 110 public async Task<ActionResult> Edit(int? id) 97 111 { 98 112 if (id == null) … … 101 115 } 102 116 CitiesClass cityClass = db.CitiesObj.Find(id); 117 //22.08 118 ViewBag.isAuthenticated = await getCrrentUser(); 103 119 if (cityClass == null) 104 120 { 105 121 return RedirectToAction("NotExist", "Error"); 106 122 } 123 // no access for standard user 124 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 125 107 126 return View(cityClass); 108 127 } … … 125 144 126 145 // GET: Customer/Delete/5 127 public ActionResult Delete(int? id) 146 // public ActionResult Delete(int? id) 147 public async Task<ActionResult> Delete(int? id) 128 148 { 149 150 UsersClass customerClass = await checkAuthorizationAsync(); 151 152 ViewBag.isAuthenticated = await getCrrentUser(); 129 153 if (id == null) 130 154 { … … 136 160 return RedirectToAction("NotExist", "Error"); 137 161 } 162 // no access for standard user 163 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 164 138 165 return View(cityClass); 139 166 } … … 161 188 162 189 163 190 164 191 } 165 192 }
Note:
See TracChangeset
for help on using the changeset viewer.