コード例 #1
0
        public ActionResult AddEmployee()
        {
            var companies  = GetCompaniesNames();
            var employeeVM = new EmployeeVMAdd()
            {
                Companies = companies,
                Company   = new CompanyVM()
            };

            return(View("AddEmployee", employeeVM));
        }
コード例 #2
0
        public RedirectToRouteResult AddEmployee(EmployeeVMAdd employeeVM)
        {
            var employeeDTO = new EmployeeDTO();

            employeeDTO.Name           = employeeVM.Name;
            employeeDTO.Surname        = employeeVM.Surname;
            employeeDTO.Patronymic     = employeeVM.Patronymic;
            employeeDTO.Position       = employeeVM.Position;
            employeeDTO.EmploymentDate = employeeVM.EmploymentDate ?? DateTime.Now;
            employeeDTO.Company        = new CompanyDTO()
            {
                CompanyName = employeeVM.Companies[0]
            };

            _service.EmployeeService.Create(employeeDTO);

            return(RedirectToAction("Index"));
        }