Example #1
0
        public ActionResult Create(EmpModel employee)
        {
            if (ModelState.IsValid)
            {
                _repository.AddEmployee(employee);

                return RedirectToAction("Index");
            }

            return View(employee);
        }
Example #2
0
 public void AddEmployee(EmpModel employee)
 {
     Employee e = new Employee() { Name = employee.Name };
     context.Employees.Add(e);
     context.SaveChanges();
 }
Example #3
0
        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);
        }