public ActionResult IzmeniSmer(SmerModel model) { if (ModelState.IsValid) { if (model.PocSem >= model.KrajSem) { model.Error = true; return(View(model)); } SmerDTO smer = new SmerDTO() { Ime = model.Ime, PocSem = model.PocSem, KrajSem = model.KrajSem }; if (model.Id == -1) { Smerovi.Dodaj(smer); } else { smer.Id = model.Id; Smerovi.Izmeni(smer); } return(RedirectToAction("AdministracijaSmerova")); } return(View(model)); }
public ActionResult IzmeniSmer(int smerId) { SmerModel model = new SmerModel(); if (smerId == -1) { model.Id = -1; model.Error = false; return(View("IzmeniSmer", model)); } else { SmerDTO smer = Smerovi.Procitaj(smerId); model.Id = smer.Id; model.Ime = smer.Ime; model.KrajSem = smer.KrajSem; model.PocSem = smer.PocSem; model.Error = false; return(View("IzmeniSmer", model)); } }