Beispiel #1
0
        public async Task <IActionResult> Create([Bind("Name,Credits,LocationId,Id")] Course course)
        {
            if (ModelState.IsValid)
            {
                _context.Add(course);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["LocationId"] = new SelectList(_context.Locations, "Id", "Id", course.LocationId);
            return(View(course));
        }
        public async Task <IActionResult> Create([Bind("DeclaredMajor,FirstName,LastName,DateOfBirth,GCIdentificationNumbe,Id")] Student student)
        {
            if (ModelState.IsValid)
            {
                student.CreatedDate     = DateTime.Now;
                student.LastUpdatedDate = DateTime.Now;
                _context.Add(student);
                await _context.SaveChangesAsync();

                _context.Dispose();
                return(RedirectToAction(nameof(Index)));
            }
            return(View(student));
        }