public ActionResult Snimi(StudiranjeUrediVM model)
        {
            if (!ModelState.IsValid)
            {
                UcitajStavke(model);

                return(View("Uredi", model));
            }

            Studiranje entity;

            if (model.Id == 0)
            {
                entity                  = new Studiranje();
                entity.Student          = new Student();
                entity.Student.Korisnik = new Korisnik();
                ctx.Studiranjes.Add(entity);
            }
            else
            {
                entity = ctx.Studiranjes
                         .Where(s => s.Id == model.Id)
                         .Include(s => s.Student.Korisnik)
                         .Single();
            }


            entity.BrojIndeksa = model.BrojIndeksa;
            entity.NppId       = model.Npp.Value;


            ctx.SaveChanges();

            return(RedirectToAction("Index"));
        }
        public ActionResult Obrisi(int studentiranjeId)
        {
            Studiranje x = ctx.Studiranjes.Find(studentiranjeId);

            ctx.Studiranjes.Remove(x);
            ctx.SaveChanges();

            return(RedirectToAction("Index"));
        }
        public ActionResult Uredi(int studentiranjeId)
        {
            Studiranje student = ctx.Studiranjes
                                 .Where(x => x.Id == studentiranjeId)
                                 .Include(x => x.Student.Korisnik)
                                 .Single();

            StudiranjeUrediVM Model = new StudiranjeUrediVM
            {
                Id          = student.Id,
                OdsjekId    = student.Npp.OdsjekId,
                BrojIndeksa = student.BrojIndeksa,
            };

            UcitajStavke(Model);


            return(View("Uredi", Model));
        }
        private static void GenerisiKorisnike(int x)
        {
            for (int i = 0; i < x; i++)
            {
                Korisnik k1 = new Korisnik
                {
                    KorisnickoIme = "korsnik" + i,
                    Lozinka       = "test",
                    Ime           = "Ime" + i,
                    Prezime       = "Prezime" + i,
                };
                korisniks.Add(k1);
                Zaposlenik z1 = new Zaposlenik()
                {
                    Korisnik = k1,
                };
                zaposleniks.Add(z1);
                Student s1 = new Student()
                {
                    Korisnik = k1,
                };
                students.Add(s1);

                Studiranje stu1 = new Studiranje
                {
                    Student             = s1,
                    BrojIndeksa         = new Guid().ToString().Substring(0, 6),
                    UgovorPocetak       = DateTime.Now.AddYears(-2),
                    StudentiranjeStatus = StudentiranjeStatus.Aktivan,
                };
                studentiranjes.Add(stu1);

                Studiranje stu2 = new Studiranje
                {
                    Student             = s1,
                    BrojIndeksa         = new Guid().ToString().Substring(0, 6),
                    UgovorPocetak       = DateTime.Now.AddYears(-1),
                    StudentiranjeStatus = StudentiranjeStatus.Aktivan,
                };
                studentiranjes.Add(stu2);
            }
        }