예제 #1
0
        public ActionResult DefineRolesStep2(string id, string newUserProfileIdentifier, FormCollection collection)
        {
            //Get SystemUsers
            SystemUser systemUser = new SystemUser();

            systemUser = systemUserRepository.GetUserBySystemUserGuid(id);

            SystemUser newSystemUser = new SystemUser();

            newSystemUser = systemUserRepository.GetUserByUserProfileIdentifier(newUserProfileIdentifier);

            //Check Exists
            if (systemUser == null || newSystemUser == null)
            {
                ViewData["ActionMethod"] = "DefineRolesStep1";
                return(View("RecordDoesNotExistError"));
            }

            //Check AccessRights
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToSystemUserRoles(systemUser.SystemUserGuid) ||
                !rolesRepository.HasWriteAccessToSystemUserRoles(newSystemUser.SystemUserGuid))
            {
                return(View("Error"));
            }

            try
            {
                systemUserRepository.CopyUserRoles(id, newSystemUser.SystemUserGuid);
            }
            catch
            {
                return(View("Error"));
            }

            return(RedirectToAction("DefineRolesCompleted", new { id = id, newUserProfileIdentifier = newUserProfileIdentifier }));
        }