Ejemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("Id,StudentName,ContactNumber")] Student student)
        {
            if (ModelState.IsValid)
            {
                _context.Add(student);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(student));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Id,CourseName,Credits")] Course course)
        {
            if (ModelState.IsValid)
            {
                _context.Add(course);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(course));
        }
        public async Task <IActionResult> Create([Bind("Id,StudentId,CourseId,Marks")] Result result)
        {
            if (ModelState.IsValid)
            {
                _context.Add(result);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourseId"]  = new SelectList(_context.Course, "Id", "Id", result.CourseId);
            ViewData["StudentId"] = new SelectList(_context.Student, "Id", "Id", result.StudentId);
            return(View(result));
        }