public ActionResult Obrisi(string id)
        {
            ProjektniZadatakEntities entities = new ProjektniZadatakEntities();
            LoginUser korisnik = entities.LoginUsers.FirstOrDefault(x => x.Username == id);

            if (korisnik != null)
            {
                entities.LoginUsers.Remove(korisnik);
                entities.SaveChanges();
            }

            return(RedirectToAction("VratiKorisnike", "Administracija"));
        }
        public ActionResult SnimiIzmene(LoginUser user)
        {
            ProjektniZadatakEntities entities = new ProjektniZadatakEntities();
            LoginUser login = entities.LoginUsers.FirstOrDefault(x => x.Username == user.Username);

            if (login != null)
            {
                login.Password      = user.Password;
                login.PravoPristupa = user.PravoPristupa;
                entities.SaveChanges();
            }

            return(RedirectToAction("VratiKorisnike"));
        }
        public ActionResult Izmeni(string id)
        {
            ProjektniZadatakEntities entities = new ProjektniZadatakEntities();
            LoginUser user = entities.LoginUsers.FirstOrDefault(x => x.Username == id);

            if (user != null)
            {
                return(View("Izmeni", user));
            }
            else
            {
                return(RedirectToAction("VratiKorisnike", "Administracija"));
            }
        }
        public ActionResult DodajNovog(LoginUser Novi)
        {
            ProjektniZadatakEntities entities = new ProjektniZadatakEntities();
            LoginUser duplikat = entities.LoginUsers.FirstOrDefault(x => x.Username == Novi.Username);

            if (duplikat == null)
            {
                entities.LoginUsers.Add(Novi);
                entities.SaveChanges();
                return(RedirectToAction("Dodaj"));
            }
            else
            {
                TempData["msg"] = "<script>alert('Korisnik sa istim korisnickim imenom vec postoji!');</script>";
                return(View("Dodaj", Novi));
            }
        }
 public ActionResult Authorize(Projektni_centar_zadatak.Models.LoginUser korisnik)
 {
     using (ProjektniZadatakEntities pze = new ProjektniZadatakEntities())
     {
         var details = pze.LoginUsers.Where(x => x.Username == korisnik.Username && x.Password == korisnik.Password).FirstOrDefault();
         if (details == null)
         {
             korisnik.LoginError = "Pogresna lozinka ili nepostojece korisnicko ime";
             return(View("Index", korisnik));
         }
         else
         {
             Session["PravoPristupa"] = details.PravoPristupa;
             Session["Username"]      = details.Username;
             return(RedirectToAction("Index", "Home"));
         }
     }
 }
        // GET: Administracija
        public ActionResult VratiKorisnike()
        {
            var korisnici = new ProjektniZadatakEntities();

            return(View(korisnici.LoginUsers.ToList()));
        }