public IActionResult Privacy(WelcomeView viewModel)
        {
            //map from view model to entity model so it can be saved in the DB
            var studentEntity = WelcomeView.mapToStudentEntity(viewModel);

            _context.Students.Add(studentEntity);
            _context.SaveChanges();
            return(View());
        }
Exemple #2
0
        public IActionResult Create(string lastName, string courseName)
        {
            var context    = new GrandCircusLmsExampleContext();
            var instructor = context.Instructors.Where(x => x.LastName == lastName).FirstOrDefault();
            var course     = context.Courses.Where(c => c.Name == courseName).FirstOrDefault();

            instructor.InstructorCourses = new List <InstructorCourse>
            {
                new InstructorCourse
                {
                    Instructor = instructor,
                    Course     = course
                }
            };
            context.Instructors.Update(instructor);
            context.SaveChanges();

            return(RedirectToAction("Index"));
        }