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)); }
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)); }