- Timestamp:
- 08/20/24 23:14:03 (3 months ago)
- Branches:
- main
- Children:
- 57fc402
- Parents:
- 63bd770
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.