Ejemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("ID,Title,Credits")] Course course)
        {
            if (ModelState.IsValid)
            {
                course.ID = Guid.NewGuid();
                _context.Add(course);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(course));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("ID,LastName,FirstMidName,EnrollmentDate")] Student student)
        {
            if (ModelState.IsValid)
            {
                student.ID = Guid.NewGuid();
                _context.Add(student);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(student));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("ID,CourseID,StudentID,LastName,Grade")] Enrollment enrollment)
        {
            if (ModelState.IsValid)
            {
                enrollment.ID = Guid.NewGuid();
                _context.Add(enrollment);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourseID"]  = new SelectList(_context.Courses, "ID", "ID", enrollment.CourseID);
            ViewData["StudentID"] = new SelectList(_context.Students, "ID", "ID", enrollment.StudentID);
            return(View(enrollment));
        }