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 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);
        }