public IActionResult DodajForma() { MojDbContext db = new MojDbContext(); KinoObjekatVM vm = new KinoObjekatVM(); vm.Adresa = db.Adresa.Select(x => new SelectListItem(x.NazivUlice, x.AdresaID.ToString())).ToList(); return(View("DodajUrediForma", vm)); }
public IActionResult Uredi(int KinoObjekatID) { if (KinoObjekatID == null) { return(RedirectToAction(nameof(Index))); } MojDbContext db = new MojDbContext(); KinoObjekat kino = db.KinoObjekat.Find(KinoObjekatID); if (kino == null) { return(RedirectToAction(nameof(Index))); } KinoObjekatVM vm = new KinoObjekatVM(); vm.Adresa = db.Adresa.Select(x => new SelectListItem(x.NazivUlice, x.AdresaID.ToString())).ToList(); vm.AdresaId = kino.AdresaId; vm.KinoID = kino.KinoID; vm.Naziv = kino.Naziv; return(View("DodajUrediForma", vm)); }
public IActionResult DodajSnimi(KinoObjekatVM kino) { MojDbContext db = new MojDbContext(); KinoObjekat k; if (kino.KinoID == 0) { k = new KinoObjekat(); db.Add(k); } else { k = db.KinoObjekat.Find(kino.KinoID); k.KinoID = kino.KinoID; } k.Naziv = kino.Naziv; k.AdresaId = kino.AdresaId; db.SaveChanges(); db.Dispose(); TempData["porukasuccess"] = "Uspjesno ste dodali kino!"; return(RedirectToAction(nameof(Index))); }