Beispiel #1
0
        public ActionResult Edit(int id)
        {
            var user = _userRepository.Get(id, "Person");

            if (user == null)
            {
                return(HttpNotFound());
            }

            var mappedRoles = _roleMemberRepository.GetAllBy(m => m.UserId == user.Id)
                              .Select(m => m.RoleId)
                              .ToList();

            var mappedTechnologies = _userTechnologyMapRepository.GetAllBy(m => m.UserId == user.Id)
                                     .Select(m => m.TechnologyId)
                                     .ToList();

            var mappedSkills = _userSkillRepository.GetAllBy(m => m.UserId == user.Id)
                               .Select(m => m.SkillId)
                               .ToList();

            var mappedHobbies = _userHobbyRepository.GetAllBy(m => m.UserId == user.Id)
                                .Select(m => m.HobbyId)
                                .ToList();

            var mappedCertifications = _userCertificationRepository.GetAllBy(m => m.UserId == user.Id)
                                       .Select(m => m.CertificationId)
                                       .ToList();

            ViewBag.Roles             = new MultiSelectList(_roleRepository.GetAll(), "Id", "Name", mappedRoles);
            ViewBag.Technologies      = new MultiSelectList(_technologyRepository.GetAll(), "Id", "Title", mappedTechnologies);
            ViewBag.Skills            = new MultiSelectList(_skillRepository.GetAll(), "Id", "Title", mappedSkills);
            ViewBag.Hobbies           = new MultiSelectList(_hobbyRepository.GetAll(), "Id", "Title", mappedHobbies);
            ViewBag.Certifications    = new MultiSelectList(_certificationRepository.GetAll(), "Id", "Title", mappedCertifications);
            ViewBag.DepartmentId      = new SelectList(_departmentRepository.GetAll(), "Id", "Title", user.DepartmentId);
            ViewBag.DesignationId     = new SelectList(_designationRepository.GetAllBy(d => d.DepartmentId == user.DepartmentId), "Id", "Title", user.DesignationId);
            ViewBag.LocationId        = new SelectList(_locationRepository.GetAll(), "Id", "Title", user.LocationId);
            ViewBag.ReportingPersonId = new SelectList(_userRepository.GetAllBy(u => u.EmployeeStatus != EmployeeStatus.Ex && u.Id != 1, "Person"), "Id", "Person.Name", user.ReportingPersonId);
            ViewBag.ManagerId         = new SelectList(_userRepository.GetAllBy(u => u.EmployeeStatus != EmployeeStatus.Ex && u.Id != 1, "Person"), "Id", "Person.Name", user.ManagerId);
            ViewBag.ShiftId           = new SelectList(_shiftRepository.GetAll(), "Id", "Title", user.ShiftId);

            var vm = new EditUserViewModel(user);

            return(View(vm));
        }