Index: PostgreSqlDotnetCore/Controllers/PetCaresController.cs
===================================================================
--- PostgreSqlDotnetCore/Controllers/PetCaresController.cs	(revision a3ce071e97bad04f989c769589a31427febe9ff3)
+++ PostgreSqlDotnetCore/Controllers/PetCaresController.cs	(revision 2aea0fddc0f6d0c25f0d44044eeb2ec5930012b9)
@@ -2,5 +2,4 @@
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.EntityFrameworkCore;
-using Microsoft.AspNetCore.Mvc.Rendering;
 using PostgreSqlDotnetCore.Models;
 using System;
@@ -15,72 +14,48 @@
         }
 
-
-        [HttpGet]
-        /*  public async Task<ActionResult> Create()
-          {
-
-              var vetCenters = await db.VetCentersObj.ToListAsync();
-
-              ViewBag.VetCenters = new SelectList(vetCenters, "id", "name");
-
-              return View();
-          }*/
-        public async Task<ActionResult> Create()
-        {
-
-
-            UsersClass customerClass = await getCrrentUser();
-
-            ViewBag.isAuthenticated = customerClass;
-            var vetCenters = await db.VetCentersObj.ToListAsync();
-            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();
-        }
-
-
-
-
         // GET: Customer
         public async Task<ActionResult> IndexAsync()
         {
             // check for permission
-            bool isAuthenticated = User.Identity.IsAuthenticated;
             UsersClass customerClass = await getCrrentUser();
-            // set if is authenticated
-            ViewBag.isAuthenticated = customerClass;
             if (customerClass == null)
             {
                 return RedirectToAction("AccessDenied", "Error");
             }
-            // no access for standard user
-            ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager);
-
             if (customerClass.role_id == RoleConstants.Standard)
             {
                 // query
-                var query = from st in db.PetCaresObj
+                            var query = from st in db.PetCaresObj
                             where st.usersid == customerClass.id
                             select st;
 
-                var userPetCares =
-                    await query.Include(n => n.PetsClass).ToListAsync<Pet_CaresClass>();
+                var userPets =
+                    //db.PetCaresObj.FromSql($"SELECT * FROM pets where usersid={customerClass.id}").ToListAsync();
+                    await query.ToListAsync<Pet_CaresClass>();
 
-                return View(userPetCares);
-            }
-            else
+                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);
+            } else
             {
-                return View(db.PetCaresObj.Include(n => n.PetsClass).ToList());
+                return View(db.PetCaresObj.ToList());
             }
 
@@ -88,5 +63,5 @@
 
         // GET: Customer/Details/5
-        public async Task<ActionResult> Details(int? id)
+        public ActionResult Details(int? id)
         {
             if (id == null)
@@ -94,6 +69,4 @@
                 return RedirectToAction("NotExist", "Error");
             }
-            UsersClass customerClass = await getCrrentUser();
-            ViewBag.isAuthenticated = customerClass;
             Pet_CaresClass peClass = db.PetCaresObj.Find(id);
             if (peClass == null)
@@ -101,7 +74,4 @@
                 return RedirectToAction("NotExist", "Error");
             }
-            // no access for standard user
-            ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager);
-
             return View(peClass);
         }
@@ -113,9 +83,9 @@
         //}
 
-        /*public ActionResult Create()
+        public ActionResult Create()
         {
             
             return View();
-        }*/
+        }
 
         // POST: Customer/Create
@@ -124,5 +94,5 @@
         [HttpPost]
         [ValidateAntiForgeryToken]
-        public async Task<ActionResult> CreateAsync([Bind(include: "id,title,description,dateending, start_date, usersid, vetcentersid, pet_id")] Pet_CaresClass peClass)
+        public async Task<ActionResult> CreateAsync([Bind(include: "id,title,description,dateending, usersid, vetcentersid")] Pet_CaresClass peClass)
         {
             bool isAuthenticated = User.Identity.IsAuthenticated;
@@ -131,16 +101,9 @@
                 return RedirectToAction("AccessDenied", "Error");
             }
-            ModelState.Remove("PetsClass");
-            ViewBag.isAuthenticated = new UsersClass();
-            // no access for standard user
-            ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager);
-            UsersClass customerClass =  null;
             if (ModelState.IsValid)
             {
-                ViewBag.isAuthenticated = new UsersClass();
                 peClass.dateending = DateTime.SpecifyKind(peClass.dateending, DateTimeKind.Utc);
-                peClass.start_date = DateTime.SpecifyKind(peClass.start_date, DateTimeKind.Utc);
                 var user = await _userManager.GetUserAsync(User);
-                customerClass = db.CustomerObj.SingleOrDefault(x => x.email == user.Email);
+                var customerClass = db.CustomerObj.SingleOrDefault(x => x.email == user.Email);
                 peClass.usersid = customerClass.id;
                 db.PetCaresObj.Add(peClass);
@@ -148,55 +111,10 @@
                 return RedirectToAction("Index");
             }
-            var vetCenters = await db.VetCentersObj.ToListAsync();
-            ViewBag.VetCenters = new SelectList(vetCenters, "id", "name");
-
-            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(peClass);
         }
 
-
-
         // GET: Customer/Edit/5
-        /*  public ActionResult Edit(int? id)
-          {
-              if (id == null)
-              {
-                  return RedirectToAction("NotExist", "Error");
-              }
-              Pet_CaresClass peClass = db.PetCaresObj.Find(id);
-              if (peClass == null)
-              {
-                  return RedirectToAction("NotExist", "Error");
-              }
-
-
-              return View(peClass);
-          }*/
-        // GET: Customer/Edit/5
-        /* public  ActionResult Edit(int? id)
-         {
-             if (id == null)
-             {
-                 return RedirectToAction("NotExist", "Error");
-             }
-             Pet_CaresClass peClass = db.PetCaresObj.Find(id);
-             if (peClass == null)
-             {
-                 return RedirectToAction("NotExist", "Error");
-             }
-
-
-             return View(peClass);
-         }*/
-        public async Task<ActionResult> Edit(int? id)
+        public ActionResult Edit(int? id)
         {
             if (id == null)
@@ -204,30 +122,11 @@
                 return RedirectToAction("NotExist", "Error");
             }
-
-            Pet_CaresClass peClass = await db.PetCaresObj.FindAsync(id);
+            Pet_CaresClass peClass = db.PetCaresObj.Find(id);
             if (peClass == null)
             {
                 return RedirectToAction("NotExist", "Error");
             }
-
-            var vetCenters = await db.VetCentersObj.ToListAsync();
-            ViewBag.VetCenters = new SelectList(vetCenters, "id", "name", peClass.vetcentersid);
-            // dodadeno na 22.08
-            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);
         }
-
-
 
         // POST: Customer/Edit/5
@@ -236,5 +135,5 @@
         [HttpPost]
         [ValidateAntiForgeryToken]
-        public async Task<ActionResult> EditAsync([Bind(include: "id,title,description,dateending, vetcentersid, pet_id")] Pet_CaresClass peClass)
+        public async Task<ActionResult> EditAsync([Bind(include: "id,title,description,dateending, vetcentersid")] Pet_CaresClass peClass)
         {
             bool isAuthenticated = User.Identity.IsAuthenticated;
@@ -243,10 +142,5 @@
                 return RedirectToAction("AccessDenied", "Error");
             }
-
-            ModelState.Remove("PetsClass");
-            ViewBag.isAuthenticated = await getCrrentUser();
-            // no access for standard user
-            ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager);
-
+             
             if (ModelState.IsValid)
             {
@@ -262,9 +156,6 @@
         }
 
-
-
-
         // GET: Customer/Delete/5
-        public async Task<ActionResult> Delete(int? id)
+        public ActionResult Delete(int? id)
         {
             if (id == null)
@@ -272,6 +163,4 @@
                 return RedirectToAction("NotExist", "Error");
             }
-            UsersClass customerClass = await getCrrentUser(); // Добијте ја тековната улога на корисникот
-            ViewBag.isAuthenticated = customerClass;
             Pet_CaresClass peClass = db.PetCaresObj.Find(id);
             if (peClass == null)
@@ -279,33 +168,15 @@
                 return RedirectToAction("NotExist", "Error");
             }
-            // no access for standard user
-            ViewBag.OnlyAdminManager = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin) ?? await checkAuthorizationSpecificRoleAsync(RoleConstants.Manager);
-
             return View(peClass);
         }
 
         // POST: Customer/Delete/5
-        /*  [HttpPost, ActionName("Delete")]
-          [ValidateAntiForgeryToken]
-          public ActionResult DeleteConfirmed(int id)
-          {
-              Pet_CaresClass peClass = db.PetCaresObj.Find(id);
-              db.PetCaresObj.Remove(peClass);
-              db.SaveChanges();
-              return RedirectToAction("Index");
-          }
-        */
-
         [HttpPost, ActionName("Delete")]
         [ValidateAntiForgeryToken]
-        public async Task<ActionResult> DeleteConfirmed(int id)
+        public ActionResult DeleteConfirmed(int id)
         {
-            Pet_CaresClass peClass = await db.PetCaresObj.FindAsync(id);
-            if (peClass == null)
-            {
-                return RedirectToAction("NotExist", "Error");
-            }
+            Pet_CaresClass peClass = db.PetCaresObj.Find(id);
             db.PetCaresObj.Remove(peClass);
-            await db.SaveChangesAsync();
+            db.SaveChanges();
             return RedirectToAction("Index");
         }
