コード例 #1
0
        public ActionResult Create(GradeViewModel grade)
        {
            if (ModelState.IsValid)
            {
                var gradeDomain = Mapper.Map <GradeViewModel, Grade>(grade);
                _gradeApp.Add(gradeDomain);

                return(RedirectToAction("Index"));
            }
            return(View(grade));
        }
コード例 #2
0
        public ActionResult Create(GradeViewModel grade)
        {
            if (ModelState.IsValid)
            {
                var subjectDomain = Mapper.Map <GradeViewModel, Grade>(grade);
                _gradeApp.Add(subjectDomain);

                return(RedirectToAction("Index"));
            }

            ViewBag.StudentId = new SelectList(_studentApp.GetAll(), "Id", "Name", grade.StudentId);
            ViewBag.SubjectId = new SelectList(_subjectApp.GetAll(), "Id", "Name", grade.SubjectId);
            return(View(grade));
        }