Changeset d6040ef for PostgreSqlDotnetCore/Controllers
- Timestamp:
- 08/20/24 23:14:03 (3 months ago)
- Branches:
- main
- Children:
- 57fc402
- Parents:
- 63bd770
- Location:
- PostgreSqlDotnetCore/Controllers
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
PostgreSqlDotnetCore/Controllers/BlogController.cs
r63bd770 rd6040ef 11 11 { 12 12 public BlogController(UserManager<IdentityUser> userManager) : base(userManager) 13 { 13 14 { 15 14 16 } 15 17 16 18 // GET: Customer 17 public async Task<ActionResult> IndexAsync() 18 { 19 // check for permission 19 /* public async Task<ActionResult> IndexAsync() 20 { 21 // check for permission 22 bool isAuthenticated = User.Identity.IsAuthenticated; 23 if (!isAuthenticated) 24 { 25 return RedirectToAction("AccessDenied", "Error"); 26 } 27 //return View(Enumerable.Empty<UsersClass>()); 28 return View(db.BlogPostControllerObj.ToList()); 29 } 30 */ 31 32 public async Task<ActionResult> Index() 33 { 34 // Проверка за автентикација 20 35 bool isAuthenticated = User.Identity.IsAuthenticated; 36 21 37 if (!isAuthenticated) 22 38 { 23 39 return RedirectToAction("AccessDenied", "Error"); 24 40 } 25 //return View(Enumerable.Empty<UsersClass>()); 26 return View(db.BlogPostControllerObj.ToList()); 27 } 28 41 42 // Список на блог постови 43 var blogPosts = await db.BlogPostControllerObj.ToListAsync(); 44 45 // Предавање на ViewBag за проверка на автентикација 46 ViewBag.isAuthenticated = isAuthenticated; 47 48 return View(blogPosts); 49 } 29 50 // GET: Customer/Details/5 30 51 public async Task<ActionResult> DetailsAsync(int? id) -
PostgreSqlDotnetCore/Controllers/CityController.cs
r63bd770 rd6040ef 16 16 // GET: Customer 17 17 public async Task<ActionResult> IndexAsync() 18 { 19 // check for permission 20 UsersClass customerClass = await checkAuthorizationAsync(); 21 if (customerClass == null) 22 { 23 return RedirectToAction("AccessDenied", "Error"); 24 } 25 //return View(Enumerable.Empty<UsersClass>()); 26 return View(db.CitiesObj.ToList()); 27 } 18 { 19 // check for permission 20 UsersClass customerClass = await checkAuthorizationAsync(); 21 if (customerClass == null) 22 { 23 return RedirectToAction("AccessDenied", "Error"); 24 } 25 //return View(Enumerable.Empty<UsersClass>()); 26 return View(db.CitiesObj.ToList()); 27 } 28 29 28 30 29 31 // GET: Customer/Details/5 -
PostgreSqlDotnetCore/Controllers/ProductsController.cs
r63bd770 rd6040ef 30 30 // set if is authenticated 31 31 ViewBag.isAuthenticated = await getCrrentUser(); 32 ViewBag.hasAccess = await checkAuthorizationAsync(); 32 33 if (!String.IsNullOrEmpty(searchString)) 33 34 { -
PostgreSqlDotnetCore/Controllers/VetCenterController.cs
r63bd770 rd6040ef 3 3 using Microsoft.EntityFrameworkCore; 4 4 using PostgreSqlDotnetCore.Models; 5 using Microsoft.AspNetCore.Mvc.Rendering; 5 6 using System.Data; 6 7 using System.Net; … … 12 13 public VetCenterController(UserManager<IdentityUser> userManager) : base(userManager) 13 14 { 14 15 // set if is authenticated 16 ViewBag.isAuthenticated = new UsersClass(); 17 } 15 } 16 17 public async Task<ActionResult> Create() 18 { 19 UsersClass customerClass = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin); 20 if (customerClass == null) 21 { 22 return RedirectToAction("AccessDenied", "Error"); 23 } 24 var citiess = await db.CitiesObj.ToListAsync(); 25 26 ViewBag.Citiess = new SelectList(citiess, "id", "name"); 27 28 return View(); 29 } 18 30 19 31 // GET: Customer 32 /* public ActionResult Index() 33 { 34 return View(db.VetCentersObj.ToList()); 35 }*/ 36 20 37 public ActionResult Index() 21 38 { 22 return View(db.VetCentersObj.ToList()); 23 } 39 var vetCenters = db.VetCentersObj.ToList(); 40 41 // Составување на списокот на ветеринарни центри и проверка на автентикацијата 42 ViewBag.isAuthenticated = User.Identity.IsAuthenticated; 43 44 return View(vetCenters); 45 } 46 24 47 25 48 // GET: Customer/Details/5 … … 39 62 40 63 // GET: Customer/Create 41 public async Task<ActionResult> CreateAsync()42 {43 // check for permission44 UsersClass customerClass = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin);45 if (customerClass == null)46 {47 return RedirectToAction("AccessDenied", "Error");48 }49 return View();50 }64 /* public async Task<ActionResult> CreateAsync() 65 { 66 // check for permission 67 UsersClass customerClass = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin); 68 if (customerClass == null) 69 { 70 return RedirectToAction("AccessDenied", "Error"); 71 } 72 return View(); 73 }*/ 51 74 52 75 // POST: Customer/Create … … 55 78 [HttpPost] 56 79 [ValidateAntiForgeryToken] 80 81 57 82 public ActionResult Create([Bind(include: "id,name,adress,description,workinghours,phonenumber,latitude,longitude,citiesid")] VetCenter vetClass) 58 83 { … … 85 110 return RedirectToAction("AccessDenied", "Error"); 86 111 } 112 var citiess = await db.CitiesObj.ToListAsync(); 113 ViewBag.Citiess = new SelectList(citiess, "id", "name", vetClass.citiesid); 87 114 return View(vetClass); 88 115 } … … 93 120 [HttpPost] 94 121 [ValidateAntiForgeryToken] 95 public ActionResult Edit([Bind(include: "id,name,adress,description,workinghours,phonenumber,latitude,longitude,citiesid")] VetCenter vetClass) 122 /* 123 public ActionResult Edit([Bind(include: "id,name,adress,description,workinghours,phonenumber,latitude,longitude,citiesid")] VetCenter vetClass) 124 { 125 if (ModelState.IsValid) 126 { 127 db.Entry(vetClass).State = EntityState.Modified; 128 db.SaveChanges(); 129 return RedirectToAction("Index"); 130 } 131 return View(vetClass); 132 }*/ 133 134 // POST: VetCenter/Edit/5 135 136 public async Task<ActionResult> Edit([Bind(include: "id,name,adress,description,workinghours,phonenumber,latitude,longitude,citiesid")] VetCenter vetClass) 96 137 { 97 138 if (ModelState.IsValid) 98 139 { 99 140 db.Entry(vetClass).State = EntityState.Modified; 100 db.SaveChanges();141 await db.SaveChangesAsync(); 101 142 return RedirectToAction("Index"); 102 143 } 103 return View(vetClass); 104 } 144 145 var citiess = await db.CitiesObj.ToListAsync(); 146 ViewBag.Citiess = new SelectList(citiess, "id", "name", vetClass.citiesid); 147 148 return View(vetClass); 149 } 150 151 105 152 106 153 // GET: Customer/Delete/5
Note:
See TracChangeset
for help on using the changeset viewer.