public ActionResult Edit(Student studentUredi) //postavimo parametar "Student" { var orginalStudent = (from s in _dbStudenti.Studenti where s.Id == studentUredi.Id select s).First(); //validacija na razini kontrolera -- strana server //eksplicitna validacija OIB-a if (!Oib.CheckOib(orginalStudent.Oib)) { ModelState.AddModelError("Oib", "Neispravan Oib"); } //provjera datuma if (orginalStudent.DatumRodenja >= DateTime.Now) { ModelState.AddModelError("DatumRodenja", "Datum rodenja treba biti manji od danasnjeg datuma"); } if (!ModelState.IsValid) //provjera ako sve stima kako je zamisljeno { return(View(orginalStudent)); } _dbStudenti.Entry(orginalStudent).CurrentValues.SetValues(studentUredi); //uzimamo bazu DBStudenti, ulaz na orginalStudent i promjenimo svojstva kako ima studentUredi _dbStudenti.SaveChanges();//spremimo promjene return(RedirectToAction("Index")); }
public override int GetHashCode() { return(Oib.GetHashCode()); }
public override bool Equals(object obj) { var emp = obj as Employee; return(emp != null && Oib.Equals(emp.Oib)); }
public void Oib_4() { Oib target = new Oib("7235"); Assert.AreEqual(false, target.IsValid); }
public void Oib_3() { Oib target = new Oib("11111111111"); Assert.AreEqual(false, target.IsValid); }
public void Oib_2() { Oib target = new Oib("44289226757"); Assert.AreEqual(true, target.IsValid); }
public void Oib_1() { Oib target = new Oib("83734260749"); Assert.AreEqual(true, target.IsValid); }