コード例 #1
0
        public async Task <IActionResult> Create([Bind("EmployeeId,FullName,Gender,Department,Company")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                _context.Add(employee);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(employee));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("Id,Dep_LastName,Dep_FirstName,Relationship,EmployeeId")] Dependent dependent)
        {
            if (ModelState.IsValid)
            {
                _context.Add(dependent);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmployeeId"] = new SelectList(_context.employees, "EmployeeId", "EmployeeId", dependent.EmployeeId);
            return(View(dependent));
        }