コード例 #1
0
ファイル: aTestController.cs プロジェクト: dcmuir01/Invest
        public ActionResult Edit()
        {
            var model = new SubjectGradesViewModel();

            // This sample data would normally be fetched
            // from your database
            var compsci = new Subject
            {
                Id = 1,
                Name = "Computer Science",
                StudentEntries = new List<Student>()
            {
            new Student { Id = 1, Name = "CompSci 1" },
            new Student { Id = 2, Name = "CompSci 2" },
            }
            };

            var maths = new Subject
            {
                Id = 2,
                Name = "Mathematics",
                StudentEntries = new List<Student>()
            {
            new Student { Id = 3, Name = "Maths 1" },
            new Student { Id = 4, Name = "Maths 2" },
            }
            };

            model.Subjects.Add(compsci);
            model.Subjects.Add(maths);

            return View(model);
        }
コード例 #2
0
ファイル: aTestController.cs プロジェクト: dcmuir01/Invest
        public ActionResult Edit(SubjectGradesViewModel model)
        {
            if (ModelState.IsValid)
            {
                return RedirectToAction("Success");
            }

            // There were validation errors
            // so redisplay the form
            return View(model);
        }