Index: PostgreSqlDotnetCore/Controllers/BlogController.cs
===================================================================
--- PostgreSqlDotnetCore/Controllers/BlogController.cs	(revision 118e414d91bed6d2f18476304a58e95728403f8c)
+++ PostgreSqlDotnetCore/Controllers/BlogController.cs	(revision e9bb9d13e39b1e74f76562e3471e4189febd2a22)
@@ -89,4 +89,6 @@
             }
             BlogPostConsultation blogClass = db.BlogPostControllerObj.Find(id);
+            UsersClass customerClass = await getCrrentUser();
+            ViewBag.isAuthenticated = customerClass;
             if (blogClass == null)
             {
@@ -102,4 +104,5 @@
             var blogAnswers = query.ToList();
             blogClass.BlogPostAnswers = blogAnswers;
+            ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager);
             return View(blogClass);
         }
@@ -121,5 +124,7 @@
 
             // check for permission
-            UsersClass customerClass = await getCrrentUser();
+            //UsersClass customerClass = await checkAuthorizationAsync();
+           // ViewBag.isAuthenticated = await getCrrentUser();
+           UsersClass customerClass = await getCrrentUser();
             // set if is authenticated
             ViewBag.isAuthenticated = customerClass;
@@ -143,4 +148,6 @@
                     var user = await _userManager.GetUserAsync(User);
                     var customerClass = db.CustomerObj.SingleOrDefault(x => x.email == user.Email);
+                   //dodadeno na 25.08
+                    ViewBag.isAuthenticated = await getCrrentUser();
                     if (customerClass != null)
                     {
@@ -184,7 +191,8 @@
             }
 
-            // check for permission
-            UsersClass customerClass = await checkAuthorizationAsync();
-            //dodadeno na 23.08
+            // izbriseno na 26.08
+           UsersClass customerClass = await checkAuthorizationAsync();
+            //dodadeno na 26.08
+           // UsersClass customerClass = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin);
             ViewBag.isAuthenticated = await getCrrentUser();
             if (customerClass == null)
@@ -204,4 +212,5 @@
             // no access for standard user
             ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager);
+            ViewBag.OnlyAdminManager1 = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager);
 
 
@@ -233,4 +242,6 @@
                 if (existingBlogClass != null)
                 {
+                    
+
                     // Запамтете ја старата вредност на users_id
                     blogClass.users_id = existingBlogClass.users_id;
@@ -247,4 +258,5 @@
 
         // GET: Customer/Delete/5
+        
         public async Task<ActionResult> DeleteAsync(int? id)
         {
@@ -286,4 +298,5 @@
         }
 
+
         // POST: Customer/Delete/5
 
@@ -298,4 +311,10 @@
             return RedirectToAction("Index");
         }
+        
+        // GET: Customer/Delete/5
+        // GET: Customer/Delete/5
+        // GET: Customer/Delete/5
+    
+
 
         protected override void Dispose(bool disposing)
Index: PostgreSqlDotnetCore/Controllers/BlogPostAnswersController.cs
===================================================================
--- PostgreSqlDotnetCore/Controllers/BlogPostAnswersController.cs	(revision 118e414d91bed6d2f18476304a58e95728403f8c)
+++ PostgreSqlDotnetCore/Controllers/BlogPostAnswersController.cs	(revision e9bb9d13e39b1e74f76562e3471e4189febd2a22)
@@ -14,12 +14,22 @@
 
         // GET: Customer
-        public ActionResult Index()
-        {
-            //return View(Enumerable.Empty<UsersClass>());
+        //public ActionResult Index()
+         public async Task<ActionResult> IndexAsync()
+         {
+             //return View(Enumerable.Empty<UsersClass>());
+             UsersClass customerClass = await getCrrentUser();
+
+             // set if is authenticated
+             ViewBag.isAuthenticated = customerClass;
+            ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager);
             return View(db.BlogPostAnswersObj.ToList());
         }
 
+
+
+
         // GET: Customer/Details/5
-        public ActionResult Details(int? id)
+        // public ActionResult Details(int? id)
+        public async Task<ActionResult> Details(int? id)
         {
             if (id == null)
@@ -27,4 +37,6 @@
                 return RedirectToAction("NotExist", "Error");
             }
+            UsersClass customerClass = await getCrrentUser(); // Добијте ја тековната улога на корисникот
+            ViewBag.isAuthenticated = customerClass;
             BlogPostAnswers answerClass = db.BlogPostAnswersObj.Find(id);
             if (answerClass == null)
@@ -32,4 +44,15 @@
                 return RedirectToAction("NotExist", "Error");
             }
+
+
+            // query
+            var query = from st in db.BlogPostAnswersObj
+                        where st.parent_id == answerClass.id
+                        select st;
+            //elenaaa
+            var answersUnderA = query.Where(x => x.id != answerClass.id).ToList();
+
+            answerClass.blogPostAnswers = answersUnderA;
+            ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager);
             return View(answerClass);
         }
@@ -46,8 +69,12 @@
             // check for permission
             UsersClass customerClass = await checkAuthorizationAsync();
+           // UsersClass customerClass = await getCrrentUser();
+            // set if is authenticated
+            ViewBag.isAuthenticated = customerClass;
             if (customerClass == null)
             {
                 return RedirectToAction("AccessDenied", "Error");
             }
+            ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager);
             return View();
         }
@@ -90,4 +117,5 @@
                 return RedirectToAction("Details", "Blog", new { id });
             }
+            ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager);
 
             return View(answerClass);
@@ -139,4 +167,5 @@
         public async Task<ActionResult> DeleteAsync(int? id)
         {
+          
             if (id == null)
             {
@@ -159,5 +188,6 @@
                 }
             }
-            return View(answerClass);
+            // return View(answerClass);
+             return View(answerClass);
         }
 
Index: PostgreSqlDotnetCore/Controllers/HomeController.cs
===================================================================
--- PostgreSqlDotnetCore/Controllers/HomeController.cs	(revision 118e414d91bed6d2f18476304a58e95728403f8c)
+++ PostgreSqlDotnetCore/Controllers/HomeController.cs	(revision e9bb9d13e39b1e74f76562e3471e4189febd2a22)
@@ -1,4 +1,5 @@
 ﻿using Microsoft.AspNetCore.Identity;
 using Microsoft.AspNetCore.Mvc;
+using Microsoft.EntityFrameworkCore;
 using PostgreSqlDotnetCore.Data;
 using PostgreSqlDotnetCore.Models;
@@ -30,5 +31,5 @@
                 if (user != null)
                 {
-                    UsersClass customerClass = db.CustomerObj.SingleOrDefault(x=> x.email == user.Email);
+                    UsersClass customerClass = db.CustomerObj.SingleOrDefault(x => x.email == user.Email);
                     if (customerClass == null)
                     {
@@ -43,5 +44,7 @@
                                 lastName = nameLastName[0].Split('.')[1];
                             }
-                        } catch(Exception ex) { 
+                        }
+                        catch (Exception ex)
+                        {
                         }
                         db.CustomerObj.Add(new UsersClass(
@@ -65,5 +68,6 @@
                 }
 
-            } else
+            }
+            else
             {
                 ViewBag.isAuthenticated = null;
@@ -86,4 +90,9 @@
         public async Task<IActionResult> ContactAsync()
         {
+
+            //var query = db.Database.ExecuteSqlRaw("CALL get_pet_details()");
+            //var query = db.Database.ExecuteSqlRaw("SELECT * FROM get_pet_details()");
+
+
             // set if is authenticated
             ViewBag.isAuthenticated = await getCrrentUser();
Index: PostgreSqlDotnetCore/Controllers/PetCaresController.cs
===================================================================
--- PostgreSqlDotnetCore/Controllers/PetCaresController.cs	(revision 118e414d91bed6d2f18476304a58e95728403f8c)
+++ PostgreSqlDotnetCore/Controllers/PetCaresController.cs	(revision e9bb9d13e39b1e74f76562e3471e4189febd2a22)
@@ -36,4 +36,15 @@
             ViewBag.VetCenters = new SelectList(vetCenters, "id", "name");
 
+
+            // check if the user is authenticated so we can take only his pets
+            if (customerClass != null)
+            {
+                var queryPetsByUser = from st in db.PetsObj
+                                      where st.usersid == customerClass.id
+                                      select st;
+                var userPets = await queryPetsByUser.ToListAsync<PetsClass>();
+                ViewBag.Pets = new SelectList(userPets, "id", "name");
+
+            }
             return View();
         }
@@ -63,29 +74,8 @@
                             select st;
 
-                var userPets =
-                    //db.PetCaresObj.FromSql($"SELECT * FROM pets where usersid={customerClass.id}").ToListAsync();
+                var userPetCares =
                     await query.ToListAsync<Pet_CaresClass>();
 
-                return View(userPets);
-
-                PetCareAllData petCareAllData = new PetCareAllData();
-                petCareAllData.PetCares = userPets;
-
-
-                // query
-                var queryVetCenters = from kk in db.VetCentersObj
-                                      select kk;
-
-                // query
-                var queryUsers = from st in db.CustomerObj
-                                 select st;
-
-                var users = await queryUsers.ToListAsync<UsersClass>();
-                petCareAllData.Users = users;
-
-                //var vetCenters = await queryVetCenters.ToListAsync<VetCenter>();
-                //petCareAllData.VetCenters = vetCenters;
-
-                return View(petCareAllData);
+                return View(userPetCares);
             }
             else
@@ -133,5 +123,5 @@
         [HttpPost]
         [ValidateAntiForgeryToken]
-        public async Task<ActionResult> CreateAsync([Bind(include: "id,title,description,dateending, start_date, usersid, vetcentersid")] Pet_CaresClass peClass)
+        public async Task<ActionResult> CreateAsync([Bind(include: "id,title,description,dateending, start_date, usersid, vetcentersid, pet_id")] Pet_CaresClass peClass)
         {
             bool isAuthenticated = User.Identity.IsAuthenticated;
@@ -143,5 +133,5 @@
             // no access for standard user
             ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager);
-
+            UsersClass customerClass =  null;
             if (ModelState.IsValid)
             {
@@ -150,5 +140,5 @@
                 peClass.start_date = DateTime.SpecifyKind(peClass.start_date, DateTimeKind.Utc);
                 var user = await _userManager.GetUserAsync(User);
-                var customerClass = db.CustomerObj.SingleOrDefault(x => x.email == user.Email);
+                customerClass = db.CustomerObj.SingleOrDefault(x => x.email == user.Email);
                 peClass.usersid = customerClass.id;
                 db.PetCaresObj.Add(peClass);
@@ -159,13 +149,14 @@
             ViewBag.VetCenters = new SelectList(vetCenters, "id", "name");
 
-            return View(peClass);
-        }
-
-
-
-
-
-
-
+
+            var queryPetsByUser = from st in db.PetsObj
+                                  where st.usersid == customerClass.id
+                                  select st;
+            var userPets =await queryPetsByUser.ToListAsync<PetsClass>();
+            ViewBag.Pets= new SelectList(userPets, "id", "name");
+
+
+            return View(peClass);
+        }
 
 
@@ -219,5 +210,16 @@
             ViewBag.VetCenters = new SelectList(vetCenters, "id", "name", peClass.vetcentersid);
             // dodadeno na 22.08
-            ViewBag.isAuthenticated = await getCrrentUser();
+            UsersClass customerClass = await getCrrentUser();
+            // check if the user is authenticated so we can take only his pets
+            if (customerClass != null)
+            {
+                var queryPetsByUser = from st in db.PetsObj
+                                      where st.usersid == customerClass.id
+                                      select st;
+                var userPets = await queryPetsByUser.ToListAsync<PetsClass>();
+                ViewBag.Pets = new SelectList(userPets, "id", "name");
+
+            }
+            ViewBag.isAuthenticated = customerClass;
             return View(peClass);
         }
@@ -230,5 +232,5 @@
         [HttpPost]
         [ValidateAntiForgeryToken]
-        public async Task<ActionResult> EditAsync([Bind(include: "id,title,description,dateending, vetcentersid")] Pet_CaresClass peClass)
+        public async Task<ActionResult> EditAsync([Bind(include: "id,title,description,dateending, vetcentersid, pet_id")] Pet_CaresClass peClass)
         {
             bool isAuthenticated = User.Identity.IsAuthenticated;
Index: PostgreSqlDotnetCore/Controllers/PetDiagnosticsControler.cs
===================================================================
--- PostgreSqlDotnetCore/Controllers/PetDiagnosticsControler.cs	(revision e9bb9d13e39b1e74f76562e3471e4189febd2a22)
+++ PostgreSqlDotnetCore/Controllers/PetDiagnosticsControler.cs	(revision e9bb9d13e39b1e74f76562e3471e4189febd2a22)
@@ -0,0 +1,94 @@
+﻿namespace PostgreSqlDotnetCore.Controllers
+{
+    using Microsoft.AspNetCore.Http;
+    using Microsoft.AspNetCore.Identity;
+    using Microsoft.AspNetCore.Mvc;
+    using Microsoft.Data.SqlClient;
+    using Microsoft.EntityFrameworkCore;
+    using PostgreSqlDotnetCore.Models;
+    using System.Threading.Tasks;
+
+    public class PetDiagnosticsControler : BaseController
+    {
+        public PetDiagnosticsControler(UserManager<IdentityUser> userManager) : base(userManager)
+        {
+
+        }
+        // GET: PetDiagnostics
+        public async Task<ActionResult> IndexAsync()
+        {
+            var query = await db.PetDetailsProcedureObj.ToListAsync();
+
+            return View();
+        }
+
+        // GET: PetDiagnostics/Details/5
+        public ActionResult Details(int id)
+        {
+            return View();
+        }
+
+        // GET: PetDiagnostics/Create
+        public ActionResult Create()
+        {
+            return View();
+        }
+
+        // POST: PetDiagnostics/Create
+        [HttpPost]
+        [ValidateAntiForgeryToken]
+        public ActionResult Create(IFormCollection collection)
+        {
+            try
+            {
+                return RedirectToAction(nameof(IndexAsync));
+            }
+            catch
+            {
+                return View();
+            }
+        }
+
+        // GET: PetDiagnostics/Edit/5
+        public ActionResult Edit(int id)
+        {
+            return View();
+        }
+
+        // POST: PetDiagnostics/Edit/5
+        [HttpPost]
+        [ValidateAntiForgeryToken]
+        public ActionResult Edit(int id, IFormCollection collection)
+        {
+            try
+            {
+                return RedirectToAction(nameof(IndexAsync));
+            }
+            catch
+            {
+                return View();
+            }
+        }
+
+        // GET: PetDiagnostics/Delete/5
+        public ActionResult Delete(int id)
+        {
+            return View();
+        }
+
+        // POST: PetDiagnostics/Delete/5
+        [HttpPost]
+        [ValidateAntiForgeryToken]
+        public ActionResult Delete(int id, IFormCollection collection)
+        {
+            try
+            {
+                return RedirectToAction(nameof(IndexAsync));
+            }
+            catch
+            {
+                return View();
+            }
+        }
+    }
+}
Index: PostgreSqlDotnetCore/Controllers/PetsController.cs
===================================================================
--- PostgreSqlDotnetCore/Controllers/PetsController.cs	(revision 118e414d91bed6d2f18476304a58e95728403f8c)
+++ PostgreSqlDotnetCore/Controllers/PetsController.cs	(revision e9bb9d13e39b1e74f76562e3471e4189febd2a22)
@@ -31,5 +31,5 @@
             if (customerClass.role_id == RoleConstants.Standard)
             {
-                // kco
+                // filter user pets by UserID
                 var query = from st in db.PetsObj
                             where st.usersid == customerClass.id
Index: PostgreSqlDotnetCore/Controllers/ProductsController.cs
===================================================================
--- PostgreSqlDotnetCore/Controllers/ProductsController.cs	(revision 118e414d91bed6d2f18476304a58e95728403f8c)
+++ PostgreSqlDotnetCore/Controllers/ProductsController.cs	(revision e9bb9d13e39b1e74f76562e3471e4189febd2a22)
@@ -48,4 +48,6 @@
         }
 
+        
+
         // GET: Customer/Details/5
         public async Task<ActionResult> Details(int? id)
@@ -55,5 +57,10 @@
                 return RedirectToAction("NotExist", "Error");
             }
-            UsersClass customerClass = await getCrrentUser(); 
+            // додано на 28.08
+         
+
+
+
+          UsersClass customerClass = await getCrrentUser(); 
             ViewBag.isAuthenticated = customerClass;
             ProductsClass prodClass = db.ProductObj.Find(id);
Index: PostgreSqlDotnetCore/Controllers/VetCenterController.cs
===================================================================
--- PostgreSqlDotnetCore/Controllers/VetCenterController.cs	(revision 118e414d91bed6d2f18476304a58e95728403f8c)
+++ PostgreSqlDotnetCore/Controllers/VetCenterController.cs	(revision e9bb9d13e39b1e74f76562e3471e4189febd2a22)
@@ -5,4 +5,6 @@
 using Microsoft.AspNetCore.Mvc.Rendering;
 using System.Threading.Tasks;
+using Npgsql;
+using PostgreSqlDotnetCore.Data;
 
 namespace PostgreSqlDotnetCore.Controllers
@@ -10,6 +12,14 @@
     public class VetCenterController : BaseController
     {
-        public VetCenterController(UserManager<IdentityUser> userManager) : base(userManager)
-        {
+        /*  
+         public VetCenterController(UserManager<IdentityUser> userManager) : base(userManager)
+           {
+           }
+        */
+        private readonly ApplicationDbContext db;
+
+        public VetCenterController(UserManager<IdentityUser> userManager, ApplicationDbContext context) : base(userManager)
+        {
+            db = context ?? throw new ArgumentNullException(nameof(context)); 
         }
 
@@ -45,14 +55,29 @@
              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()
         {
-            var vetCenters = await db.VetCentersObj.ToListAsync();
+            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);
-               // ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager);
 
             ViewBag.hasAccess = customerClass != null;
@@ -62,5 +87,6 @@
 
 
-        public async Task<ActionResult> Details(int? id)
+
+        /*public async Task<ActionResult> Details(int? id)
         {
             if (id == null)
@@ -82,4 +108,44 @@
         }
 
+
+       */
+        public async Task<IActionResult> Details(int? id)
+        {
+            if (id == null)
+            {
+                return RedirectToAction("NotExist", "Error");
+            }
+
+            // Логирајте го ID-то за дебугирање
+            Console.WriteLine($"ID: {id}");
+
+            // Обидете се да најдете запис во view
+            VetCenterWithCity vetClass = await db.VetCentersWithCity
+                                                 .Where(v => v.id == id) 
+                                                 .FirstOrDefaultAsync();
+            if (vetClass == null)
+            {
+                return RedirectToAction("NotExist", "Error");
+            }
+
+            
+            UsersClass customerClass = await getCrrentUser();
+            ViewBag.isAuthenticated = customerClass;
+
+           
+            return View(vetClass);
+        }
+
+
+
+
+
+
+
+
+
+
+
+
         [HttpPost]
         [ValidateAntiForgeryToken]
@@ -99,4 +165,46 @@
             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)
@@ -149,9 +257,10 @@
         }
 
-        public async Task<ActionResult> Delete(int? id) { 
-             UsersClass customerClass = await checkAuthorizationAsync();
-        
-        ViewBag.isAuthenticated = await getCrrentUser();
-        
+        public async Task<ActionResult> Delete(int? id)
+        {
+            UsersClass customerClass = await checkAuthorizationAsync();
+
+            ViewBag.isAuthenticated = await getCrrentUser();
+
             if (id == null)
             {
