Esempio n. 1
0
 public ActionResult Create(EmployeeCreationPage page)
 {
     if (ModelState.IsValid)
     {
         var employeesAccessor = DataAccessor.CreateInstance<EmployeesAccessor>();
         // Сохраняем нового сотрудника, получая его идентификатор
         Int64 empId = employeesAccessor.AddEmployee(page.NewEmployee.EmployeeFullName, page.NewEmployee.Age, (Int16)page.NewEmployee.Gender, page.SelectedPosition);
         // Сохраняем навыки сотрудника
         var skills = page.SelectedSkills.ToList().Select(skillId => new EmployeeSkills(empId, skillId)).ToList();
         employeesAccessor.AddEmployeeSkills(skills);
     }
     return RedirectToAction("Index");
 }
Esempio n. 2
0
        //
        // GET: /Index/Create
        public ActionResult Create()
        {
            var positions = DataAccessor.CreateInstance<PositionsAccessor>().GetPositions();
            var skillsAccessor = DataAccessor.CreateInstance<SkillsAccessor>();

            var page = new EmployeeCreationPage();

            page.PossiblePositions = positions
                .Select(p => new PositionDto
                {
                    PositionId = p.PositionId,
                    PositionName = p.PositionName,
                    Skills = skillsAccessor.GetSkills(p.PositionId)
                })
                .ToList();

            return View(page);
        }