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 Dodaj() { StudiranjeUrediVM Model = new StudiranjeUrediVM(); UcitajStavke(Model); return(View("Uredi", Model)); }
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 void UcitajStavke(StudiranjeUrediVM model) { model.OdsjekStavke = OdsjekStavke(); model.FakultetStavke = FakultetStavke(); model.NppStavke = NppStavke(); }