/// <summary> /// Create multiple users at once /// </summary> /// /// <param name="invokingUser"> /// User performing operation /// </param> /// /// <param name="users"> /// List of user objects to be created /// </param> /// /// <param name="passwordCheck"> /// Option to use password check for each user object /// </param> /// /// <returns> /// List of users that were sucessfully created and list of users who failed to be created /// </returns> public List <List <User> > BulkCreateUsers(User invokingUser, List <User> users, bool passwordCheck) { bool sufficientLength = _userManagementService.CheckListLength(users); if (!sufficientLength) { throw new ArgumentException("Insufficient list length"); } else { List <User> passedIDs = new List <User>(); List <User> failedIDs = new List <User>(); foreach (User operatedUser in users) { // Check permissions for user performing operation bool permissionCheck = _userManagementService.CheckPermission(invokingUser, operatedUser, "Create"); if (permissionCheck) { // Attempt to create user bool creationResult = _DataAccessService.CreateUser(operatedUser, passwordCheck); if (creationResult) { passedIDs.Add(operatedUser); } else { failedIDs.Add(operatedUser); } } else { failedIDs.Add(operatedUser); } } _loggingManager.Log("User Bulk Creation", ""); return(new List <List <User> > { passedIDs, failedIDs }); } }