Beispiel #1
0
        public ActionResult Update(NewUserViewModel vm)
        {
            ApiResult <User> apiResult;

            if (ModelState.IsValid)
            {
                if (vm.Id > 0)
                {
                    apiResult = TryExecute(() =>
                    {
                        var selectedUser                         = _userRepository.Get(vm.Id, "Person");
                        selectedUser.EmployeeCode                = vm.EmployeeCode;
                        selectedUser.Person.FirstName            = vm.Person.FirstName;
                        selectedUser.Person.MiddleName           = vm.Person.MiddleName;
                        selectedUser.Person.LastName             = vm.Person.LastName;
                        selectedUser.Person.Gender               = vm.Person.Gender;
                        selectedUser.Person.Email                = vm.Person.Email;
                        selectedUser.Person.PhoneNo              = vm.Person.PhoneNo;
                        selectedUser.Person.SecondaryEmail       = vm.Person.SecondaryEmail;
                        selectedUser.Person.Address              = vm.Person.Address;
                        selectedUser.Person.CommunicationAddress = vm.Person.CommunicationAddress;
                        selectedUser.Person.PassportNo           = vm.Person.PassportNo;
                        selectedUser.Person.DateOfBirth          = vm.Person.DateOfBirth;
                        selectedUser.Person.BloodGroup           = vm.Person.BloodGroup;
                        selectedUser.Person.MaritalStatus        = vm.Person.MaritalStatus;
                        selectedUser.Person.MarriageAnniversary  = vm.Person.MarriageAnniversary;
                        selectedUser.DepartmentId                = vm.DepartmentId;
                        selectedUser.LocationId                  = vm.LocationId;
                        selectedUser.DesignationId               = vm.DesignationId;
                        selectedUser.ShiftId                     = vm.ShiftId;
                        selectedUser.ReportingPersonId           = vm.ReportingPersonId;
                        selectedUser.Experience                  = vm.Experience;
                        selectedUser.DateOfJoin                  = vm.DateOfJoin;
                        selectedUser.ConfirmationDate            = vm.ConfirmationDate;
                        selectedUser.DateOfResignation           = vm.DateOfResignation;
                        selectedUser.LastDate                    = vm.LastDate;
                        selectedUser.OfficialEmail               = vm.OfficialEmail;
                        selectedUser.OfficialPhone               = vm.OfficialPhone;
                        selectedUser.OfficialMessengerId         = vm.OfficialMessengerId;
                        selectedUser.EmployeeStatus              = vm.EmployeeStatus;
                        selectedUser.RequiresTimeSheet           = vm.RequiresTimeSheet;
                        selectedUser.Salary                      = vm.Salary;
                        selectedUser.Bank                        = vm.Bank;
                        selectedUser.BankAccountNumber           = vm.BankAccountNumber;
                        selectedUser.PANCard                     = vm.PANCard;
                        selectedUser.PaymentMode                 = vm.PaymentMode;

                        _userRepository.Update(selectedUser);
                        _unitOfWork.Commit();

                        // Remove the existing mapped Roles
                        var existingRoles = _roleMemberRepository.GetAllBy(m => m.UserId == selectedUser.Id);
                        foreach (var map in existingRoles)
                        {
                            _roleMemberRepository.Delete(map);
                        }

                        if (vm.RoleIds != null)
                        {
                            // Map the New Technologies
                            foreach (var roleId in vm.RoleIds)
                            {
                                var newMap = new RoleMember
                                {
                                    UserId = vm.Id,
                                    RoleId = roleId
                                };

                                _roleMemberRepository.Create(newMap);
                            }

                            _unitOfWork.Commit();
                        }

                        // Remove the existing mapped Technologies
                        var existingMaps = _userTechnologyMapRepository.GetAllBy(m => m.UserId == selectedUser.Id);
                        foreach (var map in existingMaps)
                        {
                            _userTechnologyMapRepository.Delete(map);
                        }

                        _unitOfWork.Commit();

                        if (vm.TechnologyIds != null)
                        {
                            // Map the New Technologies
                            foreach (var technologyId in vm.TechnologyIds)
                            {
                                var newMap = new UserTechnologyMap
                                {
                                    UserId       = vm.Id,
                                    TechnologyId = technologyId
                                };

                                _userTechnologyMapRepository.Create(newMap);
                            }

                            _unitOfWork.Commit();
                        }


                        // Remove the existing mapped Skills
                        var existingSkillMaps = _userSkillRepository.GetAllBy(m => m.UserId == selectedUser.Id);
                        foreach (var map in existingSkillMaps)
                        {
                            _userSkillRepository.Delete(map);
                        }

                        _unitOfWork.Commit();

                        if (vm.SkillIds != null)
                        {
                            // Map the New Technologies
                            foreach (var skillId in vm.SkillIds)
                            {
                                var newMap = new UserSkill
                                {
                                    UserId  = vm.Id,
                                    SkillId = skillId
                                };

                                _userSkillRepository.Create(newMap);
                            }

                            _unitOfWork.Commit();
                        }

                        // Remove the existing mapped Skills
                        var existingHobbyMaps = _userHobbyRepository.GetAllBy(m => m.UserId == selectedUser.Id);
                        foreach (var map in existingHobbyMaps)
                        {
                            _userHobbyRepository.Delete(map);
                        }

                        _unitOfWork.Commit();

                        if (vm.HobbiesId != null)
                        {
                            // Map the New Technologies
                            foreach (var hobbyId in vm.HobbiesId)
                            {
                                var newMap = new UserHobby
                                {
                                    UserId  = vm.Id,
                                    HobbyId = hobbyId
                                };

                                _userHobbyRepository.Create(newMap);
                            }

                            _unitOfWork.Commit();
                        }

                        // Remove the existing mapped Certifications
                        var existingCertificationMaps =
                            _userCertificationRepository.GetAllBy(m => m.UserId == selectedUser.Id);
                        foreach (var map in existingCertificationMaps)
                        {
                            _userCertificationRepository.Delete(map);
                        }

                        _unitOfWork.Commit();

                        if (vm.CertificationIds != null)
                        {
                            // Map the New Technologies
                            foreach (var certificateId in vm.CertificationIds)
                            {
                                var newMap = new UserCertification
                                {
                                    UserId          = vm.Id,
                                    CertificationId = certificateId
                                };

                                _userCertificationRepository.Create(newMap);
                            }

                            _unitOfWork.Commit();
                        }

                        return(selectedUser);
                    }, "User updated sucessfully");
                }
                else
                {
                    apiResult = TryExecute(() =>
                    {
                        var newUser = new User
                        {
                            EmployeeCode        = vm.EmployeeCode,
                            Username            = vm.Username,
                            Password            = HashHelper.Hash(vm.Password),
                            AccessRule          = AccessRule.CreateNewUserAccessRule(true),
                            Person              = vm.Person,
                            DepartmentId        = vm.DepartmentId,
                            LocationId          = vm.LocationId,
                            DesignationId       = vm.DesignationId,
                            ShiftId             = vm.ShiftId,
                            ReportingPersonId   = vm.ReportingPersonId,
                            Experience          = vm.Experience,
                            DateOfJoin          = vm.DateOfJoin,
                            ConfirmationDate    = vm.ConfirmationDate,
                            DateOfResignation   = vm.DateOfResignation,
                            LastDate            = vm.LastDate,
                            OfficialEmail       = vm.OfficialEmail,
                            OfficialPhone       = vm.OfficialPhone,
                            OfficialMessengerId = vm.OfficialMessengerId,
                            EmployeeStatus      = vm.EmployeeStatus,
                            RequiresTimeSheet   = vm.RequiresTimeSheet,
                            Salary              = vm.Salary,
                            Bank = vm.Bank,
                            BankAccountNumber = vm.BankAccountNumber,
                            PANCard           = vm.PANCard,
                            PaymentMode       = vm.PaymentMode
                        };

                        _userRepository.Create(newUser);
                        _unitOfWork.Commit();

                        // Map the Technologies
                        if (vm.TechnologyIds != null)
                        {
                            foreach (var technologyId in vm.TechnologyIds)
                            {
                                var newMap = new UserTechnologyMap
                                {
                                    UserId       = newUser.Id,
                                    TechnologyId = technologyId
                                };
                                _userTechnologyMapRepository.Create(newMap);
                            }

                            _unitOfWork.Commit();
                        }


                        // Map the Technologies
                        if (vm.RoleIds != null)
                        {
                            foreach (var roleId in vm.RoleIds)
                            {
                                var newMap = new RoleMember
                                {
                                    UserId = newUser.Id,
                                    RoleId = roleId
                                };

                                _roleMemberRepository.Create(newMap);
                            }

                            _unitOfWork.Commit();
                        }

                        return(newUser);
                    }, "User created sucessfully");
                }
            }
            else
            {
                apiResult = ApiResultFromModelErrors <User>();
            }

            return(Json(apiResult, JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
        public JsonResult Create(EmployeeModel model)
        {
            ApiResult <Employee> apiResult;

            if (ModelState.IsValid)
            {
                if (model.Id > 0)
                {
                    apiResult = TryExecute(() =>
                    {
                        var newPerson = new Person
                        {
                            Id                   = model.PersonId,
                            FirstName            = model.FirstName,
                            MiddleName           = model.MiddleName,
                            LastName             = model.LastName,
                            Gender               = model.Gender,
                            Email                = model.Email,
                            SecondaryEmail       = model.SecondaryEmail,
                            PhoneNo              = model.PhoneNo,
                            Address              = model.Address,
                            CommunicationAddress = model.CommunicationAddress,
                            PassportNo           = model.PassportNo,
                            DateOfBirth          = model.DateOfBirth,
                            BloodGroup           = model.BloodGroup,
                            MaritalStatus        = model.MaritalStatus,
                            MarriageAnniversary  = model.MarriageAnniversary,
                            PhotoPath            = model.PhotoPath
                        };

                        _personRepository.Update(newPerson);
                        var user = _userRepository.GetBy(i => i.Id == model.UserId);

                        user.Id                  = model.UserId;
                        user.PersonId            = model.PersonId;
                        user.Username            = model.Username;
                        user.EmployeeCode        = model.EmployeeCode;
                        user.DepartmentId        = model.DepartmentId;
                        user.LocationId          = model.LocationId;
                        user.DesignationId       = model.DesignationId;
                        user.ShiftId             = model.ShiftId;
                        user.Salary              = model.Salary;
                        user.Bank                = model.Bank;
                        user.BankAccountNumber   = model.BankAccountNumber;
                        user.PANCard             = model.PANCard;
                        user.PaymentMode         = model.PaymentMode;
                        user.Experience          = model.Experience;
                        user.DateOfJoin          = model.DateOfJoin;
                        user.ConfirmationDate    = model.ConfirmationDate;
                        user.DateOfResignation   = model.DateOfResignation;
                        user.LastDate            = model.LastDate;
                        user.OfficialEmail       = model.OfficialEmail;
                        user.OfficialPhone       = model.OfficialPhone;
                        user.OfficialMessengerId = model.OfficialMessengerId;
                        user.EmployeeStatus      = model.EmployeeStatus;
                        user.RequiresTimeSheet   = model.RequiresTimeSheet;
                        user.SeatNo              = model.SeatNo;
                        user.AccessRuleId        = model.AccessRuleId;


                        _userRepository.Update(user);

                        var newEmployee = new Employee
                        {
                            Id                  = model.EmployeeId,
                            UserId              = model.UserId,
                            EmployeeCode        = model.EmployeeCode,
                            DepartmentId        = model.DepartmentId,
                            LocationId          = model.LocationId,
                            DesignationId       = model.DesignationId,
                            ShiftId             = model.ShiftId,
                            Salary              = model.Salary,
                            Bank                = model.Bank,
                            BankAccountNumber   = model.BankAccountNumber,
                            PANCard             = model.PANCard,
                            PaymentMode         = model.PaymentMode,
                            ReportingPersonId   = model.ReportingPersonId,
                            ManagerId           = model.ManagerId,
                            Experience          = model.Experience,
                            DateOfJoin          = model.DateOfJoin,
                            ConfirmationDate    = model.ConfirmationDate,
                            DateOfResignation   = model.DateOfResignation,
                            LastDate            = model.LastDate,
                            OfficialEmail       = model.OfficialEmail,
                            OfficialPhone       = model.OfficialPhone,
                            OfficialMessengerId = model.OfficialMessengerId,
                            EmployeeStatus      = model.EmployeeStatus,
                            RequiresTimeSheet   = model.RequiresTimeSheet,
                            SeatNo              = model.SeatNo
                        };
                        _employeeRepository.Update(newEmployee);
                        _unitOfWork.Commit();


                        var User = _userRepository.Get(model.UserId);
                        if (User != null)
                        {
                            var reportingPerson = _employeeRepository.Get(newEmployee.ReportingPersonId.Value);
                            var manager         = _employeeRepository.Get(newEmployee.ManagerId.Value);

                            User.ReportingPersonId = reportingPerson.UserId;
                            User.ManagerId         = manager.UserId;

                            _userRepository.Update(User);
                            _unitOfWork.Commit();
                        }

                        // Remove the existing mapped Roles
                        var existingRoles = _roleMemberRepository.GetAllBy(m => m.UserId == user.Id);
                        foreach (var map in existingRoles)
                        {
                            _roleMemberRepository.Delete(map);
                        }

                        if (model.RoleIds != null)
                        {
                            // Map the New Technologies
                            foreach (var roleId in model.RoleIds)
                            {
                                var newMap = new RoleMember
                                {
                                    UserId = model.UserId,
                                    RoleId = roleId
                                };

                                _roleMemberRepository.Create(newMap);
                            }

                            _unitOfWork.Commit();
                        }

                        // Remove the existing mapped Technologies
                        var existingMaps = _userTechnologyMapRepository.GetAllBy(m => m.UserId == model.UserId);
                        foreach (var map in existingMaps)
                        {
                            _userTechnologyMapRepository.Delete(map);
                        }

                        _unitOfWork.Commit();

                        if (model.TechnologyIds != null)
                        {
                            // Map the New Technologies
                            foreach (var technologyId in model.TechnologyIds)
                            {
                                var newMap = new UserTechnologyMap
                                {
                                    UserId       = model.UserId,
                                    TechnologyId = technologyId
                                };

                                _userTechnologyMapRepository.Create(newMap);
                            }

                            _unitOfWork.Commit();
                        }

                        return(newEmployee);
                    }, "Employee updated sucessfully");
                }
                else
                {
                    apiResult = TryExecute(() =>
                    {
                        var newPerson = new Person
                        {
                            FirstName            = model.FirstName,
                            MiddleName           = model.MiddleName,
                            LastName             = model.LastName,
                            Gender               = model.Gender,
                            Email                = model.Email,
                            SecondaryEmail       = model.SecondaryEmail,
                            PhoneNo              = model.PhoneNo,
                            Address              = model.Address,
                            CommunicationAddress = model.CommunicationAddress,
                            PassportNo           = model.PassportNo,
                            DateOfBirth          = model.DateOfBirth,
                            BloodGroup           = model.BloodGroup,
                            MaritalStatus        = model.MaritalStatus,
                            MarriageAnniversary  = model.MarriageAnniversary,
                            PhotoPath            = model.PhotoPath
                        };
                        var person = _personRepository.Create(newPerson);

                        var newUser = new User
                        {
                            PersonId            = person.Id,
                            Username            = model.Username,
                            Password            = HashHelper.Hash(model.Password),
                            AccessRule          = AccessRule.CreateNewUserAccessRule(true),
                            EmployeeCode        = model.EmployeeCode,
                            DepartmentId        = model.DepartmentId,
                            LocationId          = model.LocationId,
                            DesignationId       = model.DesignationId,
                            ShiftId             = model.ShiftId,
                            Salary              = model.Salary,
                            Bank                = model.Bank,
                            BankAccountNumber   = model.BankAccountNumber,
                            PANCard             = model.PANCard,
                            PaymentMode         = model.PaymentMode,
                            Experience          = model.Experience,
                            DateOfJoin          = model.DateOfJoin,
                            ConfirmationDate    = model.ConfirmationDate,
                            DateOfResignation   = model.DateOfResignation,
                            LastDate            = model.LastDate,
                            OfficialEmail       = model.OfficialEmail,
                            OfficialPhone       = model.OfficialPhone,
                            OfficialMessengerId = model.OfficialMessengerId,
                            EmployeeStatus      = model.EmployeeStatus,
                            RequiresTimeSheet   = model.RequiresTimeSheet,
                            SeatNo              = model.SeatNo,
                        };
                        var user = _userRepository.Create(newUser);

                        var newEmployee = new Employee
                        {
                            UserId              = user.Id,
                            EmployeeCode        = model.EmployeeCode,
                            DepartmentId        = model.DepartmentId,
                            LocationId          = model.LocationId,
                            DesignationId       = model.DesignationId,
                            ShiftId             = model.ShiftId,
                            Salary              = model.Salary,
                            Bank                = model.Bank,
                            BankAccountNumber   = model.BankAccountNumber,
                            PANCard             = model.PANCard,
                            PaymentMode         = model.PaymentMode,
                            ReportingPersonId   = model.ReportingPersonId,
                            ManagerId           = model.ManagerId,
                            Experience          = model.Experience,
                            DateOfJoin          = model.DateOfJoin,
                            ConfirmationDate    = model.ConfirmationDate,
                            DateOfResignation   = model.DateOfResignation,
                            LastDate            = model.LastDate,
                            OfficialEmail       = model.OfficialEmail,
                            OfficialPhone       = model.OfficialPhone,
                            OfficialMessengerId = model.OfficialMessengerId,
                            EmployeeStatus      = model.EmployeeStatus,
                            RequiresTimeSheet   = model.RequiresTimeSheet,
                            SeatNo              = model.SeatNo
                        };
                        _employeeRepository.Create(newEmployee);
                        _unitOfWork.Commit();


                        var User = _userRepository.Get(newUser.Id);
                        if (User != null)
                        {
                            var reportingPerson = _employeeRepository.Get(newEmployee.ReportingPersonId.Value);
                            var manager         = _employeeRepository.Get(newEmployee.ManagerId.Value);

                            User.ReportingPersonId = reportingPerson.UserId;
                            User.ManagerId         = manager.UserId;

                            _userRepository.Update(User);
                            _unitOfWork.Commit();
                        }

                        // Map the Technologies
                        if (model.TechnologyIds != null)
                        {
                            foreach (var technologyId in model.TechnologyIds)
                            {
                                var newMap = new UserTechnologyMap
                                {
                                    UserId       = newUser.Id,
                                    TechnologyId = technologyId
                                };
                                _userTechnologyMapRepository.Create(newMap);
                            }

                            _unitOfWork.Commit();
                        }

                        // Map the Roles
                        if (model.RoleIds != null)
                        {
                            foreach (var roleId in model.RoleIds)
                            {
                                var newMap = new RoleMember
                                {
                                    UserId = newUser.Id,
                                    RoleId = roleId
                                };

                                _roleMemberRepository.Create(newMap);
                            }

                            _unitOfWork.Commit();
                        }



                        return(newEmployee);
                    }, "Employee created sucessfully");
                }
            }
            else
            {
                apiResult = ApiResultFromModelErrors <Employee>();
                var data = ApiResultFromModelErrors <Employee>();
            }
            return(Json(apiResult, JsonRequestBehavior.AllowGet));
        }
Beispiel #3
0
        public ActionResult Seed(Tenant tenant)
        {
            var selectedTenant = db.Tenants.Find(tenant.Id);

            if (selectedTenant != null)
            {
                var connectionString = selectedTenant.ConnectionString;
                if (!string.IsNullOrEmpty(connectionString))
                {
                    using (var context = new GridDataContext(connectionString))
                    {
                        var accessRule = AccessRule.CreateNewUserAccessRule(true);
                        context.AccessRules.Add(accessRule);
                        context.SaveChanges();

                        var person = new Person();
                        context.Persons.Add(person);
                        context.SaveChanges();

                        var manageCompany = new Permission {
                            Title = "Manage Company", PermissionCode = 200
                        };
                        context.Permissions.Add(manageCompany);
                        var manageHRMS = new Permission {
                            Title = "Manage HRMS", PermissionCode = 210
                        };
                        context.Permissions.Add(manageHRMS);
                        var manageSales = new Permission {
                            Title = "Manage Sales", PermissionCode = 220
                        };
                        context.Permissions.Add(manageSales);
                        var manageIT = new Permission {
                            Title = "Manage IT", PermissionCode = 230
                        };
                        context.Permissions.Add(manageIT);
                        var managePMS = new Permission {
                            Title = "Manage PMS", PermissionCode = 240
                        };
                        context.Permissions.Add(managePMS);
                        var manageInventory = new Permission {
                            Title = "Manage Inventory", PermissionCode = 250
                        };
                        context.Permissions.Add(manageInventory);
                        var manageLMS = new Permission {
                            Title = "Manage LMS", PermissionCode = 215
                        };
                        context.Permissions.Add(manageLMS);
                        var manageTimeSheet = new Permission {
                            Title = "Manage TimeSheet", PermissionCode = 300
                        };
                        context.Permissions.Add(manageTimeSheet);
                        var manageRecruit = new Permission {
                            Title = "Manage Recruit", PermissionCode = 500
                        };
                        context.Permissions.Add(manageRecruit);
                        var superPermission = new Permission {
                            Title = "Super Permission", PermissionCode = 9999
                        };
                        context.Permissions.Add(superPermission);
                        var manageTMS = new Permission {
                            Title = "Manage TMS", PermissionCode = 550
                        };
                        context.Permissions.Add(manageTMS);
                        var manageKBS = new Permission {
                            Title = "Manage KBS", PermissionCode = 700
                        };
                        context.Permissions.Add(manageKBS);
                        var viewSettings = new Permission {
                            Title = "View Settings", PermissionCode = 909
                        };
                        context.Permissions.Add(viewSettings);
                        var manageCRM = new Permission {
                            Title = "Manage CRM", PermissionCode = 222
                        };
                        context.Permissions.Add(manageCRM);
                        var manageTicketDesk = new Permission {
                            Title = "Manage Ticket Desk", PermissionCode = 1100
                        };
                        context.Permissions.Add(manageTicketDesk);
                        context.SaveChanges();

                        var adminRole = new Role {
                            Name = "Admin"
                        };
                        context.Roles.Add(adminRole);
                        context.SaveChanges();

                        // Role Permission Mapping
                        var permissions = context.Permissions.ToList();
                        foreach (var permission in permissions)
                        {
                            var newMap = new RolePermission
                            {
                                RoleId       = adminRole.Id,
                                PermissionId = permission.Id
                            };

                            context.RolePermissions.Add(newMap);
                        }
                        context.SaveChanges();

                        // Create User
                        var user = new User
                        {
                            EmployeeCode = "Code",
                            Username     = selectedTenant.Email,
                            Password     = HashHelper.Hash("123456"),
                            AccessRuleId = accessRule.Id,
                            PersonId     = person.Id
                        };

                        context.Users.Add(user);
                        context.SaveChanges();

                        // Role Member Mapping
                        var newMember = new RoleMember
                        {
                            RoleId = adminRole.Id,
                            UserId = user.Id
                        };

                        context.RoleMembers.Add(newMember);
                        context.SaveChanges();

                        return(RedirectToAction("Index"));
                    }
                }
            }
            return(View(tenant));
        }
Beispiel #4
0
        public ActionResult Create(NewUserViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var newUser = new User
                {
                    EmployeeCode        = vm.EmployeeCode,
                    Username            = vm.Username,
                    Password            = HashHelper.Hash(vm.Password),
                    AccessRule          = AccessRule.CreateNewUserAccessRule(true),
                    Person              = vm.Person,
                    DepartmentId        = vm.DepartmentId,
                    LocationId          = vm.LocationId,
                    DesignationId       = vm.DesignationId,
                    ShiftId             = vm.ShiftId,
                    ReportingPersonId   = vm.ReportingPersonId,
                    ManagerId           = vm.ManagerId,
                    Experience          = vm.Experience,
                    DateOfJoin          = vm.DateOfJoin,
                    ConfirmationDate    = vm.ConfirmationDate,
                    DateOfResignation   = vm.DateOfResignation,
                    LastDate            = vm.LastDate,
                    OfficialEmail       = vm.OfficialEmail,
                    OfficialPhone       = vm.OfficialPhone,
                    OfficialMessengerId = vm.OfficialMessengerId,
                    EmployeeStatus      = vm.EmployeeStatus,
                    RequiresTimeSheet   = vm.RequiresTimeSheet,
                    Salary              = vm.Salary,
                    Bank = vm.Bank,
                    BankAccountNumber = vm.BankAccountNumber,
                    PANCard           = vm.PANCard,
                    PaymentMode       = vm.PaymentMode
                };

                _userRepository.Create(newUser);
                _unitOfWork.Commit();

                // Map the Technologies
                if (vm.TechnologyIds != null)
                {
                    foreach (var technologyId in vm.TechnologyIds)
                    {
                        var newMap = new UserTechnologyMap
                        {
                            UserId       = newUser.Id,
                            TechnologyId = technologyId
                        };
                        _userTechnologyMapRepository.Create(newMap);
                    }

                    _unitOfWork.Commit();
                }

                return(RedirectToAction("Index"));
            }

            ViewBag.Roles             = new MultiSelectList(_roleRepository.GetAll(), "Id", "Name", vm.RoleIds);
            ViewBag.Technologies      = new MultiSelectList(_technologyRepository.GetAll(), "Id", "Title", vm.TechnologyIds);
            ViewBag.DepartmentId      = new SelectList(_departmentRepository.GetAll(), "Id", "Title", vm.DepartmentId);
            ViewBag.DesignationId     = new SelectList(_designationRepository.GetAll(), "Id", "Title", vm.DesignationId);
            ViewBag.LocationId        = new SelectList(_locationRepository.GetAll(), "Id", "Title", vm.LocationId);
            ViewBag.ReportingPersonId = new SelectList(_userRepository.GetAll("Person"), "Id", "Person.Name", vm.ReportingPersonId);
            ViewBag.ManagerId         = new SelectList(_userRepository.GetAll("Person"), "Id", "Person.Name", vm.ManagerId);
            ViewBag.ShiftId           = new SelectList(_shiftRepository.GetAll(), "Id", "Title", vm.ShiftId);

            return(View(vm));
        }