public ActionResult Create(EmpModel employee) { if (ModelState.IsValid) { _repository.AddEmployee(employee); return RedirectToAction("Index"); } return View(employee); }
public void AddEmployee(EmpModel employee) { Employee e = new Employee() { Name = employee.Name }; context.Employees.Add(e); context.SaveChanges(); }
public ActionResult Update(EmpModel employee) { if (ModelState.IsValid) { Employee emp = _repository.GetEmployeeById(employee.Id); emp.Name = employee.Name; _repository.UpdateEmployee(emp); return RedirectToAction("Index"); } return View(employee); }