public IActionResult Snimi(PutniciKorisniciUrediVM input) { PutnikKorisnik k; if (input.PutnikKorisnikID == 0) { k = new PutnikKorisnik(); db.Add(k); } else { k = db.PutnikKorisnik.Find(input.PutnikKorisnikID); } k.PutnikKorisnikId = input.PutnikKorisnikID; k.KorisnikId = input.KorisnikID; db.SaveChanges(); if (input.PutnikKorisnikID == 0) { TempData["poruka-success"] = "Uspjesno ste dodali putnika"; } else { TempData["poruka-success"] = "Uspjesno ste izmijenili podatke putnika"; } db.Dispose(); return(RedirectToAction(nameof(Prikazi))); }
public IActionResult Dodaj() { PutniciKorisniciUrediVM model = new PutniciKorisniciUrediVM(); model.korisnici = db.Klijent.Select(o => new SelectListItem(o.Ime + " " + o.Prezime, o.Id.ToString())).ToList(); return(View("Uredi", model)); }
public IActionResult Uredi(int PutnikKorisnikID) { PutnikKorisnik k = db.PutnikKorisnik.Find(PutnikKorisnikID); if (k == null) { return(RedirectToAction(nameof(Prikazi))); } PutniciKorisniciUrediVM model = new PutniciKorisniciUrediVM(); model.korisnici = db.Klijent.Select(o => new SelectListItem(o.Ime + " " + o.Prezime, o.Id.ToString())).ToList(); model.KorisnikID = k.KorisnikId; return(View("Uredi", model)); }