Exemplo n.º 1
0
        public ActionResult Edit(Employee employee)
        {
            if (!ModelState.IsValid)
                return View(new EmployeeViewModel(employee));

            _repository.Update(employee);
            return RedirectToAction("Index");
        }
Exemplo n.º 2
0
        public EmployeeViewModel(Employee employee)
        {
            Employee = employee;

            var dbContext = new OrgChartDbContext();
            JobTitles = new SelectList(new JobTitleRepository(dbContext).SelectAll().OrderBy(_ => _.Description), "Id", "Description", employee.JobTitleId);
            Departments = new SelectList(new DepartmentRepository(dbContext).SelectAll(), "Id", "Name", employee.DepartmentId);
            Managers = new SelectList(new EmployeeRepository(dbContext).SelectAll().Where(_ => _.IsManager).OrderBy(_ => _.LastName), "Id", "LastName", employee.ManagerId);
        }
Exemplo n.º 3
0
        public void SetUp()
        {
            _dbcontext = new OrgChartDbContext();
            _employee = new Employee
            {
                FirstName = "Test",
                LastName = "Person",
                JobTitleId = null,
                IsManager = false,
                ManagerId = null,
                DepartmentId = null,
            };

            _dbcontext.Employees.Add(_employee);
            _dbcontext.SaveChanges();
        }