public IActionResult Create(EmployeesCreateVM employee) { if (!ModelState.IsValid) { return(View(employee)); } service.AddEmployee(employee); return(RedirectToAction(nameof(Index))); }
public void AddEmployee(EmployeesCreateVM viewModel) { //emp.ID = idCounter++; context.Employees.Add(new Employee { Name = viewModel.Name, Email = viewModel.Email }); context.SaveChanges(); }