コード例 #1
0
        public ActionResult Edit(int id = 0)
        {
            var employee = EmployeeHandler.GetEmployee(id);

            var employeeModel = EmployeeModelMapper.MapToEmployeeModel(employee);

            return(View(employeeModel));
        }
コード例 #2
0
        public ViewResult Index(bool includeNonActive = false)
        {
            var model = new EmployeeIndexModel();

            model.IncludeNonActive = includeNonActive;

            var empList = EmployeeHandler.GetAllEmployee(includeNonActive);

            foreach (var emp in empList)
            {
                var empModel = EmployeeModelMapper.MapToEmployeeModel(emp);
                model.EmployeeList.Add(empModel);
            }

            return(View(model));
        }
コード例 #3
0
        public ActionResult Add(EmployeeModel model)
        {
            var employee = EmployeeModelMapper.MapToEmployee(model);

            try
            {
                employee.IsActive = true;
                EmployeeHandler.Add(employee);
            }
            catch (Exception ex)
            {
                model.Error = ex.Message;
                return(View("Add", model));
            }

            var empModel = EmployeeModelMapper.MapToEmployeeModel(employee);

            return(View("Add", empModel));
        }