Changeset 118e414
- Timestamp:
- 08/23/24 15:40:14 (2 months ago)
- Branches:
- main
- Children:
- e9bb9d1
- Parents:
- 72b1da2
- Location:
- PostgreSqlDotnetCore
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
PostgreSqlDotnetCore/Controllers/BlogController.cs
r72b1da2 r118e414 13 13 14 14 { 15 15 16 16 } 17 17 … … 49 49 }*/ 50 50 51 public async Task<ActionResult> Index() 52 { 53 // Проверка за автентикација 54 bool isAuthenticated = User.Identity.IsAuthenticated; 55 56 if (!isAuthenticated) 57 { 58 return RedirectToAction("AccessDenied", "Error"); 59 } 60 61 // Список на блог постови 62 var blogPosts = await db.BlogPostControllerObj.ToListAsync(); 63 64 // Вземи тековниот корисник 65 var currentUser = await _userManager.GetUserAsync(User); 66 var customerClass = await db.CustomerObj.SingleOrDefaultAsync(x => x.email == currentUser.Email); 67 68 // Предавање на ViewBag за проверка на автентикација и корисничкиот ID 69 ViewBag.isAuthenticated = isAuthenticated; 70 ViewBag.CurrentUserId = customerClass?.id; 71 72 return View(blogPosts); 73 } 74 75 76 51 public async Task<ActionResult> Index() 52 { 53 // Проверка за автентикација 54 bool isAuthenticated = User.Identity.IsAuthenticated; 55 56 if (!isAuthenticated) 57 { 58 return RedirectToAction("AccessDenied", "Error"); 59 } 60 61 // Список на блог постови 62 var blogPosts = await db.BlogPostControllerObj.ToListAsync(); 63 64 // Вземи тековниот корисник 65 var currentUser = await _userManager.GetUserAsync(User); 66 var customerClass = await db.CustomerObj.SingleOrDefaultAsync(x => x.email == currentUser.Email); 67 68 // Предавање на ViewBag за проверка на автентикација и корисничкиот ID 69 ViewBag.isAuthenticated = isAuthenticated; 70 // no access for standard user 71 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 72 73 ViewBag.CurrentUserId = customerClass?.id; 74 75 return View(blogPosts); 76 } 77 78 79 77 80 78 81 … … 121 124 // set if is authenticated 122 125 ViewBag.isAuthenticated = customerClass; 126 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 127 123 128 return View(); 124 129 } … … 197 202 } 198 203 } 204 // no access for standard user 205 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 206 199 207 200 208 return View(blogClass); … … 217 225 }*/ 218 226 219 227 220 228 public async Task<ActionResult> EditAsync(int id, [Bind(include: "id,date_askes,title,description")] BlogPostConsultation blogClass) 221 229 { … … 239 247 240 248 // GET: Customer/Delete/5 241 public async Task<ActionResult> DeleteAsync(int? id) { 242 // UsersClass customerClass = await checkAuthorizationAsync(); 243 244 ViewBag.isAuthenticated = await getCrrentUser(); 245 249 public async Task<ActionResult> DeleteAsync(int? id) 250 { 251 // UsersClass customerClass = await checkAuthorizationAsync(); 252 253 ViewBag.isAuthenticated = await getCrrentUser(); 254 246 255 if (id == null) 247 {248 return View(null);249 //return new HttpStatusCodeResult(HttpStatusCode.BadRequest);250 } 251 BlogPostConsultation blogClass = db.BlogPostControllerObj.Find(id);256 { 257 return View(null); 258 //return new HttpStatusCodeResult(HttpStatusCode.BadRequest); 259 } 260 BlogPostConsultation blogClass = db.BlogPostControllerObj.Find(id); 252 261 if (blogClass == null) 253 262 { 254 263 return View(null); 255 //return HttpNotFound();264 //return HttpNotFound(); 256 265 } 257 266 // check for permission … … 271 280 } 272 281 } 282 // no access for standard user 283 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 284 273 285 return View(blogClass); 274 286 } 275 287 276 288 // POST: Customer/Delete/5 277 289 278 290 279 291 [HttpPost, ActionName("Delete")] -
PostgreSqlDotnetCore/Controllers/BlogPostAnswersController.cs
r72b1da2 r118e414 58 58 [HttpPost] 59 59 [ValidateAntiForgeryToken] 60 public ActionResult Create([Bind(include: "id,parent_id,reply,root_post,usersID")] BlogPostAnswers answerClass)60 public async Task<ActionResult> CreateAsync(int? id, int? parentId, [Bind(include: "reply")] BlogPostAnswers answerClass) 61 61 { 62 if (ModelState.IsValid) 62 63 //string id = Request.Query["BlogId"]; 64 if (id == null && id > 0) 63 65 { 66 return RedirectToAction("NotExist", "Error"); 67 } 68 //string id = Request.Query["BlogId"]; 69 if (parentId== null && parentId > 0) 70 { 71 return RedirectToAction("NotExist", "Error"); 72 } 73 if (answerClass != null && answerClass.reply.Length > 0) 74 { 75 76 var user = await _userManager.GetUserAsync(User); 77 if (user == null) 78 { 79 return RedirectToAction("AccessDenied", "Error"); 80 } 81 82 83 var customerClass = db.CustomerObj.SingleOrDefault(x => x.email == user.Email); 84 answerClass.usersid = customerClass.id; 85 answerClass.BlogPostConsultationid = (int)id; 86 answerClass.parent_id = (int)parentId; 64 87 db.BlogPostAnswersObj.Add(answerClass); 65 88 db.SaveChanges(); 66 return RedirectToAction("Index"); 89 //return RedirectToAction("Index"); 90 return RedirectToAction("Details", "Blog", new { id }); 67 91 } 68 92 -
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 } -
PostgreSqlDotnetCore/Controllers/CustomerController.cs
r72b1da2 r118e414 19 19 public async Task<ActionResult> IndexAsync() 20 20 { 21 UsersClass customerClass = await getCrrentUser(); 21 UsersClass customerClass = await getCrrentUser(); 22 23 ViewBag.isAuthenticated = User.Identity.IsAuthenticated; 24 ViewBag.CanCreate = customerClass.role_id == RoleConstants.Admin || customerClass.role_id == RoleConstants.Manager; 25 // no access for standard user 26 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 27 22 28 if (customerClass == null) 23 29 { … … 41 47 return View(db.CustomerObj.ToList()); 42 48 } 43 49 50 44 51 } 45 52 … … 57 64 // check for permission 58 65 UsersClass customerClass = await getCrrentUser(); 66 ViewBag.isAuthenticated = customerClass; 59 67 if (customerClass == null) 60 68 { … … 67 75 return RedirectToAction("NotExist", "Error"); 68 76 } 77 // no access for standard user 78 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 79 69 80 return View(customerClass); 70 81 } … … 73 84 public async Task<ActionResult> CreateAsync() 74 85 { 86 //ViewBag.CanCreate = customerClass.role_id == RoleConstants.Admin || customerClass.role_id == RoleConstants.Manager; 87 75 88 // check for permission 76 UsersClass customerClass = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin); 77 if (customerClass == null) 78 { 79 return RedirectToAction("AccessDenied", "Error"); 80 } 89 UsersClass customerClass = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 90 //dodano na 23.08 91 ViewBag.isAuthenticated = await getCrrentUser(); 92 if (customerClass == null) 93 { 94 return RedirectToAction("AccessDenied", "Error"); 95 } 96 // no access for standard user 97 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 98 81 99 82 100 return View(); … … 125 143 126 144 customerClass = db.CustomerObj.Find(id); 145 ViewBag.isAuthenticated = await getCrrentUser(); 127 146 if (customerClass == null) 128 147 { … … 130 149 //return HttpNotFound(); 131 150 } 151 // no access for standard user 152 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 153 132 154 return View(customerClass); 133 155 } … … 159 181 } 160 182 UsersClass customerClass = await getCrrentUser(); 161 if (customerClass == null) 162 { 163 return RedirectToAction("AccessDenied", "Error"); 164 } 183 ViewBag.isAuthenticated = await getCrrentUser(); 184 if (customerClass == null) 185 { 186 return RedirectToAction("AccessDenied", "Error"); 187 } 188 189 // no access for standard user 190 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 165 191 return View(customerClass); 166 192 } -
PostgreSqlDotnetCore/Controllers/ErrorController.cs
r72b1da2 r118e414 4 4 using Microsoft.AspNetCore.Identity; 5 5 using Microsoft.AspNetCore.Mvc; 6 using PostgreSqlDotnetCore.Models; 6 7 using System.Threading.Tasks; 7 8 … … 17 18 // set if is authenticated 18 19 ViewBag.isAuthenticated = await getCrrentUser(); 20 // no access for standard user 21 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 22 19 23 return View(); 20 24 } … … 24 28 // set if is authenticated 25 29 ViewBag.isAuthenticated = await getCrrentUser(); 30 // no access for standard user 31 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 32 26 33 return View(); 27 34 } -
PostgreSqlDotnetCore/Controllers/HomeController.cs
r72b1da2 r118e414 59 59 // set if is authenticated 60 60 ViewBag.isAuthenticated = await getCrrentUser(); 61 // проба на 23.08 62 // no access for standard user 63 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 64 61 65 } 62 66 … … 75 79 // set if is authenticated 76 80 ViewBag.isAuthenticated = await getCrrentUser(); 81 // no access for standard user 82 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 83 77 84 return View(); 78 85 } … … 81 88 // set if is authenticated 82 89 ViewBag.isAuthenticated = await getCrrentUser(); 90 // no access for standard user 91 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 92 83 93 return View(); 84 94 } -
PostgreSqlDotnetCore/Controllers/PetCaresController.cs
r72b1da2 r118e414 26 26 return View(); 27 27 }*/ 28 29 30 31 28 public async Task<ActionResult> Create() 29 { 30 31 32 32 UsersClass customerClass = await getCrrentUser(); 33 33 34 34 ViewBag.isAuthenticated = customerClass; 35 35 var vetCenters = await db.VetCentersObj.ToListAsync(); 36 37 38 39 40 41 36 ViewBag.VetCenters = new SelectList(vetCenters, "id", "name"); 37 38 return View(); 39 } 40 41 42 42 43 43 … … 53 53 return RedirectToAction("AccessDenied", "Error"); 54 54 } 55 // no access for standard user 56 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 57 55 58 if (customerClass.role_id == RoleConstants.Standard) 56 59 { 57 60 // query 58 61 var query = from st in db.PetCaresObj 59 62 where st.usersid == customerClass.id 60 63 select st; … … 72 75 // query 73 76 var queryVetCenters = from kk in db.VetCentersObj 74 select kk;77 select kk; 75 78 76 79 // query … … 85 88 86 89 return View(petCareAllData); 87 } else 90 } 91 else 88 92 { 89 93 return View(db.PetCaresObj.ToList()); … … 99 103 return RedirectToAction("NotExist", "Error"); 100 104 } 101 UsersClass customerClass = await getCrrentUser(); 105 UsersClass customerClass = await getCrrentUser(); 102 106 ViewBag.isAuthenticated = customerClass; 103 107 Pet_CaresClass peClass = db.PetCaresObj.Find(id); … … 106 110 return RedirectToAction("NotExist", "Error"); 107 111 } 112 // no access for standard user 113 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 114 108 115 return View(peClass); 109 116 } … … 126 133 [HttpPost] 127 134 [ValidateAntiForgeryToken] 128 129 130 131 132 133 134 135 public async Task<ActionResult> CreateAsync([Bind(include: "id,title,description,dateending, start_date, usersid, vetcentersid")] Pet_CaresClass peClass) 136 { 137 bool isAuthenticated = User.Identity.IsAuthenticated; 138 if (!isAuthenticated) 139 { 140 return RedirectToAction("AccessDenied", "Error"); 141 } 135 142 ViewBag.isAuthenticated = new UsersClass(); 143 // no access for standard user 144 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 136 145 137 146 if (ModelState.IsValid) 138 147 { 139 148 ViewBag.isAuthenticated = new UsersClass(); 140 149 peClass.dateending = DateTime.SpecifyKind(peClass.dateending, DateTimeKind.Utc); 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 150 peClass.start_date = DateTime.SpecifyKind(peClass.start_date, DateTimeKind.Utc); 151 var user = await _userManager.GetUserAsync(User); 152 var customerClass = db.CustomerObj.SingleOrDefault(x => x.email == user.Email); 153 peClass.usersid = customerClass.id; 154 db.PetCaresObj.Add(peClass); 155 db.SaveChanges(); 156 return RedirectToAction("Index"); 157 } 158 var vetCenters = await db.VetCentersObj.ToListAsync(); 159 ViewBag.VetCenters = new SelectList(vetCenters, "id", "name"); 160 161 return View(peClass); 162 } 163 164 165 166 167 159 168 160 169 … … 229 238 } 230 239 ViewBag.isAuthenticated = await getCrrentUser(); 240 // no access for standard user 241 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 231 242 232 243 if (ModelState.IsValid) … … 260 271 return RedirectToAction("NotExist", "Error"); 261 272 } 273 // no access for standard user 274 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 275 262 276 return View(peClass); 263 277 } -
PostgreSqlDotnetCore/Controllers/PetsController.cs
r72b1da2 r118e414 26 26 return RedirectToAction("AccessDenied", "Error"); 27 27 } 28 // no access for standard user 29 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 30 28 31 if (customerClass.role_id == RoleConstants.Standard) 29 32 { 30 33 // kco 31 34 var query = from st in db.PetsObj 32 35 where st.usersid == customerClass.id 33 36 select st; … … 37 40 await query.ToListAsync<PetsClass>(); 38 41 return View(userPets); 39 } else 42 } 43 else 40 44 { 41 45 return View(db.PetsObj.ToList()); … … 74 78 return RedirectToAction("NotExist", "Error"); 75 79 } 80 // no access for standard user 81 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 82 76 83 77 84 return View(peClass); … … 109 116 } 110 117 ViewBag.isAuthenticated = new UsersClass(); 118 // no access for standard user 119 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 111 120 112 121 if (ModelState.IsValid) … … 119 128 peClass.usersid = customerClass.id; 120 129 // voa go pisav tuka na 18.02 121 // PetsClass.dateofbirthday = DateOnly.FromDateTime(DateTime.UtcNow);130 // PetsClass.dateofbirthday = DateOnly.FromDateTime(DateTime.UtcNow); 122 131 db.PetsObj.Add(peClass); 123 132 db.SaveChanges(); … … 143 152 // додадено на 21.08 144 153 ViewBag.isAuthenticated = await getCrrentUser(); 154 // no access for standard user 155 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 156 145 157 return View(peClass); 146 158 } … … 167 179 ViewBag.isAuthenticated = await getCrrentUser(); 168 180 //ViewBag.isAuthenticated = new UsersClass(); 169 170 181 // no access for standard user 182 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 183 184 171 185 if (ModelState.IsValid) 172 186 { 173 187 //peClass.dateofbirthday = DateTime.SpecifyKind(peClass.dateofbirthday, DateTimeKind.Utc); 174 188 175 189 var user = await _userManager.GetUserAsync(User); 176 190 var customerClass = db.CustomerObj.SingleOrDefault(x => x.email == user.Email); … … 213 227 return RedirectToAction("NotExist", "Error"); 214 228 } 229 // no access for standard user 230 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 231 215 232 216 233 return View(peClass); -
PostgreSqlDotnetCore/Controllers/ProductsController.cs
r72b1da2 r118e414 31 31 ViewBag.isAuthenticated = await getCrrentUser(); 32 32 ViewBag.hasAccess = await checkAuthorizationAsync(); 33 // no access for standard user 34 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 35 33 36 if (!String.IsNullOrEmpty(searchString)) 34 37 { … … 59 62 return RedirectToAction("NotExist", "Error"); 60 63 } 64 // no access for standard user 65 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 66 61 67 return View(prodClass); 62 68 } … … 79 85 return RedirectToAction("AccessDenied", "Error"); 80 86 } 87 // no access for standard user 88 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 89 81 90 var model = new ProductsClass 82 91 { -
PostgreSqlDotnetCore/Controllers/VetCenterController.cs
r72b1da2 r118e414 23 23 return RedirectToAction("AccessDenied", "Error"); 24 24 } 25 // no access for standard user 26 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 25 27 26 28 // Fetch cities for dropdown … … 47 49 var vetCenters = await db.VetCentersObj.ToListAsync(); 48 50 ViewBag.isAuthenticated = User.Identity.IsAuthenticated; 51 // no access for standard user 52 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 49 53 50 54 // Проверете дали корисникот е администратор или менаџер … … 66 70 67 71 VetCenter vetClass = await db.VetCentersObj.FindAsync(id); 72 UsersClass customerClass = await getCrrentUser(); 73 ViewBag.isAuthenticated = customerClass; 68 74 if (vetClass == null) 69 75 { 70 76 return RedirectToAction("NotExist", "Error"); 71 77 } 78 // no access for standard user 79 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 72 80 73 81 return View(vetClass); … … 113 121 return RedirectToAction("AccessDenied", "Error"); 114 122 } 123 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 124 115 125 116 126 // Fetch cities for dropdown … … 154 164 return RedirectToAction("NotExist", "Error"); 155 165 } 166 ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager); 167 156 168 157 169 return View(vetClass); -
PostgreSqlDotnetCore/Views/Blog/Details.cshtml
r72b1da2 r118e414 80 80 @Html.ActionLink("Details", "Details", "BlogPostAnswers", new { id = item.id }) | 81 81 @Html.ActionLink("Delete", "Delete", "BlogPostAnswers", new { id = item.id }) 82 83 @Html.ActionLink("Create an Answer", "Create", "BlogPostAnswers", new { id = item.BlogPostConsultationid, parentId = item.id }) 82 84 </td> 83 85 </tr> … … 87 89 </div> 88 90 <p> 91 @Html.ActionLink("Create an Answer", "Create", "BlogPostAnswers", new { id = Model.id, parentId = Model.id }) 89 92 @Html.ActionLink("Edit", "Edit", new { id = Model.id }) | 90 93 @Html.ActionLink("Back to List", "Index") -
PostgreSqlDotnetCore/Views/Blog/Index.cshtml
r72b1da2 r118e414 29 29 </tr> 30 30 31 @foreach (var item in Model) { 32 <tr> 33 <td> 34 @Html.DisplayFor(modelItem => item.date_askes) 35 </td> 36 <td> 37 @Html.DisplayFor(modelItem => item.title) 38 </td> 31 @foreach (var item in Model) 32 { 33 <tr> 34 <td> 35 @Html.DisplayFor(modelItem => item.date_askes) 36 </td> 37 <td> 38 @Html.DisplayFor(modelItem => item.title) 39 </td> 39 40 40 <td>41 @Html.DisplayFor(modelItem => item.description)42 </td>43 <th>44 @Html.DisplayFor(model => item.users_id)45 </th>41 <td> 42 @Html.DisplayFor(modelItem => item.description) 43 </td> 44 <th> 45 @Html.DisplayFor(model => item.users_id) 46 </th> 46 47 47 @*<td>48 49 50 48 @*<td> 49 @Html.ActionLink("Edit", "Edit", new { id = item.id }) | 50 @Html.ActionLink("Answers", "Details", new { id = item.id }) | 51 @Html.ActionLink("Delete", "Delete", new { id = item.id }) 51 52 </td> 52 53 *@ 53 54 54 55 55 56 56 57 @if (item.users_id == ViewBag.CurrentUserId) 58 { 59 <td> 60 @Html.ActionLink("Edit", "Edit", new { id = item.id }) 61 @Html.ActionLink("Delete", "Delete", new { id = item.id }) 62 63 </td> 57 58 @if (item.users_id == ViewBag.CurrentUserId) 59 { 60 <td> 61 @Html.ActionLink("Edit", "Edit", new { id = item.id }) 62 @Html.ActionLink("Delete", "Delete", new { id = item.id }) 63 64 </td> 64 65 } 65 66 66 67 67 68 68 @if (item.users_id == ViewBag.CurrentUserId || item.users_id != ViewBag.CurrentUserId) 69 69 { 70 70 <td> 71 72 @Html.ActionLink("Answers", "Details", new { id = item.id }) 73 71 72 @Html.ActionLink("Answers", "Details", new { id = item.id }) 73 74 74 75 75 </td> 76 76 } 77 78 77 79 78 80 81 82 83 </tr> 84 } 79 80 81 82 83 </tr> 84 } 85 85 86 86 </table> -
PostgreSqlDotnetCore/Views/BlogPostAnswers/Create.cshtml
r72b1da2 r118e414 17 17 @Html.ValidationSummary(true, "", new { @class = "text-danger" }) 18 18 19 <div class="form-group">19 @* <div class="form-group"> 20 20 @Html.LabelFor(model => model.parent_id, htmlAttributes: new { @class = "control-label col-md-2" }) 21 21 <div class="col-md-10"> … … 24 24 </div> 25 25 </div> 26 26 *@ 27 27 <div class="form-group"> 28 28 @Html.LabelFor(model => model.reply, htmlAttributes: new { @class = "control-label col-md-2" }) -
PostgreSqlDotnetCore/Views/BlogPostAnswers/Details.cshtml
r72b1da2 r118e414 31 31 <p> 32 32 @Html.ActionLink("Edit", "Edit", new { id = Model.id }) | 33 @Html.ActionLink("Back to List", "Index") 33 @* @Html.ActionLink("Back to List", "Index") *@ 34 <a href="javascript:void(0);" onclick="history.go(-1);">Back to List</a> 34 35 </p> -
PostgreSqlDotnetCore/Views/Customer/Index.cshtml
r72b1da2 r118e414 17 17 { 18 18 19 <p>19 /* <p> 20 20 @Html.ActionLink("Create New", "Create") 21 21 </p> 22 */ 23 24 @if (ViewBag.CanCreate) 25 { 26 <p> 27 @Html.ActionLink("Create New", "Create") 28 </p> 29 } 22 30 <table class="table"> 23 31 <tr> -
PostgreSqlDotnetCore/Views/Shared/_Layout.cshtml
r72b1da2 r118e414 13 13 </head> 14 14 <body> 15 <h1>@(ViewBag.isAuthenticated == null ? "krij" : "prikazi")</h1>15 @* <h1>@(ViewBag.isAuthenticated == null ? "krij" : "prikazi")</h1> *@ 16 16 <header> 17 17 <nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3"> … … 47 47 <a class="nav-link text-dark" asp-area="" asp-controller="Customer" asp-action="Index">Manage Customers</a> 48 48 </li> 49 <li class="nav-item">49 @* <li class="nav-item"> 50 50 <a class="nav-link text-dark" asp-area="" asp-controller="City" asp-action="Index">Manage Cities</a> 51 51 </li> 52 52 *@ 53 53 <li class="nav-item"> 54 54 <a class="nav-link text-dark" asp-area="" asp-controller="Blog" asp-action="Index">BlogPost</a> … … 56 56 } 57 57 58 59 58 60 59 61 } 62 @if (ViewBag.OnlyAdminManager != null) 63 { 64 <li class="nav-item"> 65 <a class="nav-link text-dark" asp-area="" asp-controller="City" asp-action="Index">Manage Cities</a> 66 </li> 67 } 68 60 69 61 70
Note:
See TracChangeset
for help on using the changeset viewer.