Index: PostgreSqlDotnetCore/Controllers/VetCenterController.cs
===================================================================
--- PostgreSqlDotnetCore/Controllers/VetCenterController.cs	(revision a3ce071e97bad04f989c769589a31427febe9ff3)
+++ PostgreSqlDotnetCore/Controllers/VetCenterController.cs	(revision 2aea0fddc0f6d0c25f0d44044eeb2ec5930012b9)
@@ -3,8 +3,6 @@
 using Microsoft.EntityFrameworkCore;
 using PostgreSqlDotnetCore.Models;
-using Microsoft.AspNetCore.Mvc.Rendering;
-using System.Threading.Tasks;
-using Npgsql;
-using PostgreSqlDotnetCore.Data;
+using System.Data;
+using System.Net;
 
 namespace PostgreSqlDotnetCore.Controllers
@@ -12,83 +10,16 @@
     public class VetCenterController : BaseController
     {
-        /*  
-         public VetCenterController(UserManager<IdentityUser> userManager) : base(userManager)
-           {
-           }
-        */
-        private readonly ApplicationDbContext db;
-
-        public VetCenterController(UserManager<IdentityUser> userManager, ApplicationDbContext context) : base(userManager)
+        public VetCenterController(UserManager<IdentityUser> userManager) : base(userManager)
         {
-            db = context ?? throw new ArgumentNullException(nameof(context)); 
         }
 
-        public async Task<ActionResult> Create()
+        // GET: Customer
+        public ActionResult Index()
         {
-            // Set if user is authenticated
-            UsersClass customerClass = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin);
-            ViewBag.isAuthenticated = await getCrrentUser();
-            if (customerClass == null)
-            {
-                return RedirectToAction("AccessDenied", "Error");
-            }
-            // no access for standard user
-            ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager);
-
-            // Fetch cities for dropdown
-            var citiess = await db.CitiesObj.ToListAsync();
-            ViewBag.Citiess = new SelectList(citiess, "id", "name");
-
-            return View();
+            return View(db.VetCentersObj.ToList());
         }
 
-        /* public async Task<ActionResult> Index()
-         {
-
-             var vetCenters = await db.VetCentersObj.ToListAsync();
-             ViewBag.isAuthenticated = User.Identity.IsAuthenticated;
-
-             // Check if the user is an admin
-             UsersClass customerClass = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin);
-             ViewBag.hasAccess = customerClass != null;
-
-             return View(vetCenters);
-         }*/
-        /* public async Task<ActionResult> Index()
-         {
-             var vetCenters = await db.VetCentersObj.ToListAsync();
-             ViewBag.isAuthenticated = User.Identity.IsAuthenticated;
-             // no access for standard user
-             ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager);
-
-             // Проверете дали корисникот е администратор или менаџер
-             UsersClass customerClass = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin);
-             // ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager);
-
-             ViewBag.hasAccess = customerClass != null;
-
-             return View(vetCenters);
-         }
-     */
-        public async Task<ActionResult> Index()
-        {
-            ViewBag.isAuthenticated = await getCrrentUser();
-            ViewBag.hasAccess = await checkAuthorizationAsync();
-            var vetCenters = await db.VetCentersWithCity.ToListAsync(); 
-           // ViewBag.isAuthenticated = User.Identity.IsAuthenticated;
-            // no access for standard user
-            ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager);
-
-            
-            UsersClass customerClass = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin);
-
-            ViewBag.hasAccess = customerClass != null;
-
-            return View(vetCenters);
-        }
-
-
-
-        /*public async Task<ActionResult> Details(int? id)
+        // GET: Customer/Details/5
+        public ActionResult Details(int? id)
         {
             if (id == null)
@@ -96,21 +27,43 @@
                 return RedirectToAction("NotExist", "Error");
             }
-
-            VetCenter vetClass = await db.VetCentersObj.FindAsync(id);
-            UsersClass customerClass = await getCrrentUser();
-            ViewBag.isAuthenticated = customerClass;
+            VetCenter vetClass = db.VetCentersObj.Find(id);
             if (vetClass == null)
             {
                 return RedirectToAction("NotExist", "Error");
             }
-            // no access for standard user
-            ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager);
+            return View(vetClass);
+        }
+
+        // GET: Customer/Create
+        public async Task<ActionResult> CreateAsync()
+        {
+            // check for permission
+            UsersClass customerClass = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin);
+            if (customerClass == null)
+            {
+                return RedirectToAction("AccessDenied", "Error");
+            }
+            return View();
+        }
+
+        // POST: Customer/Create
+        // To protect from overposting attacks, enable the specific properties you want to bind to, for 
+        // more details see https://go.microsoft.com/fwlink/?LinkId=317598.
+        [HttpPost]
+        [ValidateAntiForgeryToken]
+        public ActionResult Create([Bind(include: "id,name,adress,description,workinghours,phonenumber,latitude,longitude,citiesid")] VetCenter vetClass)
+        {
+            if (ModelState.IsValid)
+            {
+                db.VetCentersObj.Add(vetClass);
+                db.SaveChanges();
+                return RedirectToAction("Index");
+            }
 
             return View(vetClass);
         }
 
-
-       */
-        public async Task<IActionResult> Details(int? id)
+        // GET: Customer/Edit/5
+        public async Task<ActionResult> EditAsync(int? id)
         {
             if (id == null)
@@ -118,97 +71,36 @@
                 return RedirectToAction("NotExist", "Error");
             }
-
-            // Логирајте го ID-то за дебугирање
-            Console.WriteLine($"ID: {id}");
-
-            // Обидете се да најдете запис во view
-            VetCenterWithCity vetClass = await db.VetCentersWithCity
-                                                 .Where(v => v.id == id) 
-                                                 .FirstOrDefaultAsync();
+            VetCenter vetClass = db.VetCentersObj.Find(id);
             if (vetClass == null)
             {
                 return RedirectToAction("NotExist", "Error");
             }
-
-            
-            UsersClass customerClass = await getCrrentUser();
-            ViewBag.isAuthenticated = customerClass;
-
-           
+            // check for permission
+            UsersClass customerClass = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin);
+            if (customerClass == null)
+            {
+                return RedirectToAction("AccessDenied", "Error");
+            }
             return View(vetClass);
         }
 
-
-
-
-
-
-
-
-
-
-
-
+        // POST: Customer/Edit/5
+        // To protect from overposting attacks, enable the specific properties you want to bind to, for 
+        // more details see https://go.microsoft.com/fwlink/?LinkId=317598.
         [HttpPost]
         [ValidateAntiForgeryToken]
-        public async Task<ActionResult> Create([Bind(include: "id,name,adress,description,workinghours,phonenumber,latitude,longitude,citiesid")] VetCenter vetClass)
+        public ActionResult Edit([Bind(include: "id,name,adress,description,workinghours,phonenumber,latitude,longitude,citiesid")] VetCenter vetClass)
         {
             if (ModelState.IsValid)
             {
-                db.VetCentersObj.Add(vetClass);
-                await db.SaveChangesAsync();
+                db.Entry(vetClass).State = EntityState.Modified;
+                db.SaveChanges();
                 return RedirectToAction("Index");
             }
-
-            // If model is invalid, repopulate the cities for dropdown
-            var citiess = await db.CitiesObj.ToListAsync();
-            ViewBag.Citiess = new SelectList(citiess, "id", "name", vetClass.citiesid);
-
             return View(vetClass);
         }
 
-   
-
-         /*public async Task<ActionResult> Create([Bind(include: "id,name,adress,description,workinghours,phonenumber,latitude,longitude,citiesid")] VetCenter vetClass)
-         {
-             // Логирање на параметрите
-             Console.WriteLine($"Parameters: {vetClass.name}, {vetClass.adress}, {vetClass.description}, {vetClass.workinghours}, {vetClass.phonenumber}, {vetClass.latitude}, {vetClass.longitude}, {vetClass.citiesid}");
-
-             if (ModelState.IsValid)
-             {
-                 // Повик на складираната процедура
-                 var parameters = new[]
-                 {
-             new NpgsqlParameter("@name", vetClass.name),
-             new NpgsqlParameter("@adress", vetClass.adress),
-             new NpgsqlParameter("@description", vetClass.description),
-             new NpgsqlParameter("@workinghours", vetClass.workinghours),
-             new NpgsqlParameter("@phonenumber", vetClass.phonenumber),
-             new NpgsqlParameter("@latitude", (decimal)vetClass.latitude),
-             new NpgsqlParameter("@longitude", (decimal)vetClass.longitude),
-             new NpgsqlParameter("@citiesid", vetClass.citiesid)
-         };
-
-                 await db.Database.ExecuteSqlRawAsync("CALL project.AddVetCenter(@name, @adress, @description, @workinghours, @phonenumber, @latitude, @longitude, @citiesid)", parameters);
-
-                 return RedirectToAction("Index");
-             }
-
-             // Ако моделот не е валиден, повторно пополнете ги градовите за паѓачкиот мени
-             var citiess = await db.CitiesObj.ToListAsync();
-             ViewBag.Citiess = new SelectList(citiess, "id", "name", vetClass.citiesid);
-
-             return View(vetClass);
-         }
-
-         
-
-
-        */
-
-
-
-
-        public async Task<ActionResult> Edit(int? id)
+        // GET: Customer/Delete/5
+        public ActionResult Delete(int? id)
         {
             if (id == null)
@@ -216,76 +108,20 @@
                 return RedirectToAction("NotExist", "Error");
             }
-
-            VetCenter vetClass = await db.VetCentersObj.FindAsync(id);
+            VetCenter vetClass = db.VetCentersObj.Find(id);
             if (vetClass == null)
             {
                 return RedirectToAction("NotExist", "Error");
             }
-
-            // Check for permission
-            UsersClass customerClass = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin);
-            //UsersClass customerClass = await checkAuthorizationAsync();
-            ViewBag.isAuthenticated = await getCrrentUser();
-            if (customerClass == null)
-            {
-                return RedirectToAction("AccessDenied", "Error");
-            }
-            ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager);
-
-
-            // Fetch cities for dropdown
-            var citiess = await db.CitiesObj.ToListAsync();
-            ViewBag.Citiess = new SelectList(citiess, "id", "name", vetClass.citiesid);
-
             return View(vetClass);
         }
 
-        [HttpPost]
-        [ValidateAntiForgeryToken]
-        public async Task<ActionResult> Edit([Bind(include: "id,name,adress,description,workinghours,phonenumber,latitude,longitude,citiesid")] VetCenter vetClass)
-        {
-            if (ModelState.IsValid)
-            {
-                db.Entry(vetClass).State = EntityState.Modified;
-                await db.SaveChangesAsync();
-                return RedirectToAction("Index");
-            }
-
-            // If model is invalid, repopulate the cities for dropdown
-            var citiess = await db.CitiesObj.ToListAsync();
-            ViewBag.Citiess = new SelectList(citiess, "id", "name", vetClass.citiesid);
-
-            return View(vetClass);
-        }
-
-        public async Task<ActionResult> Delete(int? id)
-        {
-            UsersClass customerClass = await checkAuthorizationAsync();
-
-            ViewBag.isAuthenticated = await getCrrentUser();
-
-            if (id == null)
-            {
-                return RedirectToAction("NotExist", "Error");
-            }
-
-            VetCenter vetClass = await db.VetCentersObj.FindAsync(id);
-            if (vetClass == null)
-            {
-                return RedirectToAction("NotExist", "Error");
-            }
-            ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager);
-
-
-            return View(vetClass);
-        }
-
+        // POST: Customer/Delete/5
         [HttpPost, ActionName("Delete")]
         [ValidateAntiForgeryToken]
-        public async Task<ActionResult> DeleteConfirmed(int id)
+        public ActionResult DeleteConfirmed(int id)
         {
-            VetCenter vetClass = await db.VetCentersObj.FindAsync(id);
+            VetCenter vetClass = db.VetCentersObj.Find(id);
             db.VetCentersObj.Remove(vetClass);
-            await db.SaveChangesAsync();
+            db.SaveChanges();
             return RedirectToAction("Index");
         }
@@ -300,17 +136,22 @@
         }
 
-        public async Task<ActionResult> IndexWithSearch(string searchTerm)
+
+        // GET: VetCenter/Search
+        public ActionResult IndexWithSearch(string searchTerm)
         {
             if (string.IsNullOrEmpty(searchTerm))
             {
-                var vetCenters = await db.VetCentersObj.ToListAsync();
+                var vetCenters = db.VetCentersObj.ToList();
                 return View(vetCenters);
             }
             else
             {
-                var searchResults = await db.VetCentersObj.Where(vc => vc.name.Contains(searchTerm)).ToListAsync();
+                var searchResults = db.VetCentersObj.Where(vc => vc.name.Contains(searchTerm)).ToList();
                 return View(searchResults);
             }
         }
+
+
+
     }
 }
