示例#1
0
        public async Task <IActionResult> Create([Bind("Id,DeptName")] Department department)
        {
            if (ModelState.IsValid)
            {
                _context.Add(department);
                await _context.SaveChangesAsync();

                ViewBag.SuccessMsg = "Successfully Added";
                return(RedirectToAction(nameof(Index)));
            }
            return(View(department));
        }
示例#2
0
        public async Task <IActionResult> Create([Bind("EmpId,Name,Role,Location,Age,Salary,DeptId")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                //int DeptID = int.Parse(this.RouteData.Values["DeptId"].ToString());
                int id = employee.DeptId = DepID;

                _context.Add(employee);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(employee));
        }