private void GenerisiCmbStavke(DolasciDodajVM model) { model.ZaposleniciList = _db.Zaposlenik.Select(s => new SelectListItem { Text = s.Ime + " " + s.Prezime, Value = s.Id.ToString() }).ToList(); }
public IActionResult Dodaj() { DolasciDodajVM model = new DolasciDodajVM(); GenerisiCmbStavke(model); return(View(model)); }
public IActionResult DodajSave(DolasciDodajVM model) { if (ModelState.IsValid) { Dolasci d = new Dolasci(); _db.Add(d); d.SatiRadio = 0; d.Dolazak = DateTime.Now; d.Odlazak = null; d.ZaposlenikId = model.ZaposlenikId; _db.SaveChanges(); return(RedirectToAction("List")); } else { GenerisiCmbStavke(model); return(View("Dodaj", model)); } }