Пример #1
0
        public IActionResult Add(GradeViewModels gradeViewModel)
        {
            if (ModelState.IsValid) //if form validation is valid,then
            {
                //instantiate a grade object
                Grade grade = new Grade
                {
                    ID    = gradeViewModel.ID,
                    Level = gradeViewModel.Level,
                };
                context.Grades.Add(grade); //save context to the database
                context.SaveChanges();

                return(Redirect("Index"));
            }
            return(View(gradeViewModel)); //if model state failed, prompt the add grade form
        }
Пример #2
0
        public IActionResult Add()
        {
            GradeViewModels gradeViewModels = new GradeViewModels();

            return(View(gradeViewModels));
        }