Esempio n. 1
0
        public IActionResult Index()
        {
            var model = new StudentiIndexVM
            {
                studenti = VirtualDB.student,
                opisi    = new List <string> {
                    "str1", "str2",
                },
            };

            return(View("index", model));
        }
Esempio n. 2
0
        public IActionResult Index()
        {
            var model = new StudentiIndexVM
            {
                studenti = nesto._studenti.ToList(),
                opisi    = new List <string> {
                    "str1", "str2",
                },
            };

            return(View("index", model));
        }
        public IActionResult Index(string searchString = null)
        {
            KorisnickiNalog korisnik = HttpContext.GetLogiraniKorisnik();
            Zaposlenik      z        = _context.Zaposlenici.Where(x => x.KorisnickiNalogId == korisnik.Id).FirstOrDefault();

            if (korisnik == null || z == null || z._VrstaZaposlenikaId != 1)
            {
                TempData["error_poruka"] = "Nemate pravo pristupa!";
                return(Redirect("/Autentifikacija/Index"));
            }
            if (!String.IsNullOrEmpty(searchString))
            {
                StudentiIndexVM modelS = new StudentiIndexVM
                {
                    Rows = _context.Studenti.Where(s => s.Ime.Contains(searchString) || s.Ime.Contains(searchString)).Select(x => new StudentiIndexVM.Row
                    {
                        Id      = x.Id,
                        Ime     = x.Ime,
                        Prezime = x.Prezime,
                        Spol    = x.Spol,
                        Jmbg    = x.JMBG,
                        Grad    = x._Grad.Naziv,
                        Email   = x.Mail,
                        Soba_   = _context.StudentiSobe.Where(s => s._StudentId == x.Id).FirstOrDefault()._Soba.Naziv
                    }).ToList()
                };

                return(View("Index", modelS));
            }
            else
            {
                StudentiIndexVM model = new StudentiIndexVM
                {
                    Rows = _context.Studenti.Select(x => new StudentiIndexVM.Row
                    {
                        Id      = x.Id,
                        Ime     = x.Ime,
                        Prezime = x.Prezime,
                        Spol    = x.Spol,
                        Jmbg    = x.JMBG,
                        Grad    = x._Grad.Naziv,
                        Email   = x.Mail,
                        Soba_   = _context.StudentiSobe.Where(s => s._StudentId == x.Id).FirstOrDefault()._Soba.Naziv
                    }).ToList()
                };
                return(View("Index", model));
            }
        }