示例#1
0
        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));
        }
示例#4
0
        public void Oib_4()
        {
            Oib target = new Oib("7235");

            Assert.AreEqual(false, target.IsValid);
        }
示例#5
0
        public void Oib_3()
        {
            Oib target = new Oib("11111111111");

            Assert.AreEqual(false, target.IsValid);
        }
示例#6
0
        public void Oib_2()
        {
            Oib target = new Oib("44289226757");

            Assert.AreEqual(true, target.IsValid);
        }
示例#7
0
        public void Oib_1()
        {
            Oib target = new Oib("83734260749");

            Assert.AreEqual(true, target.IsValid);
        }