コード例 #1
0
        public ActionResult saveStudent(FakultetViewModel model)
        {
            try
            {
                Fakultet1Entities db = new Fakultet1Entities();

                Student s = new Student();
                s.BrIndeksa = model.BrIndeksa;
                s.IdS       = model.IdS;
                s.Ime       = model.Ime;
                s.Prezime   = model.Prezime;
                s.Grad      = model.Grad;

                db.Students.Add(s);
                db.SaveChanges();
                db.Configuration.LazyLoadingEnabled = false;
            }
            catch (Exception ex)
            {
                throw ex;
            }



            return(RedirectToAction("Index"));
        }
コード例 #2
0
        public ActionResult DodajStudenta(Student student)
        {
            string message = "Uspesno sacuvano!";
            bool   status  = true;

            if (db2.Students.ToList().Count == 0)
            {
                student.IdS = 1;
            }
            else
            {
                student.IdS = db2.Students.Max(x => x.IdS) + 1;
            }

            db2.Students.Add(student);
            db2.SaveChanges();

            return(Json(new { status = status, message = message }, JsonRequestBehavior.AllowGet));

            db2.Configuration.LazyLoadingEnabled = false;
        }