Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public ActionResult Edit(SubjectGradesViewModel model)
        {
            if (ModelState.IsValid)
            {
                return RedirectToAction("Success");
            }

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