Esempio n. 1
0
        public PartialViewResult Index(StudentViewModel vm)
        {
            TestEntities context = new TestEntities();
            context.Students.Add(vm.newStudent);
            context.SaveChanges();

            return PartialView("_StudentListControl",context.Students);
        }
Esempio n. 2
0
        public ActionResult Index()
        {
            ViewBag.Message = "Welcome to ASP.NET MVC!";

            TestEntities context = new TestEntities();
            StudentViewModel viewModel = new StudentViewModel
            {
                Students = context.Students

            };

            return View(viewModel);
        }
Esempio n. 3
0
        public PartialViewResult Index(StudentViewModel vm, string Action)
        {
            TestEntities context = new TestEntities();
            if (Action == "Add Student")
            {

                context.Students.Add(vm.newStudent);
                context.SaveChanges();
            }
            else
            {
                foreach( Student s in context.Students)
                {
                    s.Age += 1;

                }
                context.SaveChanges();
            }

            return PartialView("_StudentListControl",context.Students);
        }