public void CreateUserWithRole(CreateUserPanelWithRoleCommand command) { var user = new PanelUser(command.UserName, command.FirstName, command.LastName, command.NationalCode, command.MobileNumber, command.Email); var identityResult = _panelRepository .RegisterUserWithRole(user, new IdentityRole(command.RoleName), command.Password).Result; if (identityResult == null) { throw new CustomException(" Internal Server Error"); } if (!identityResult.Succeeded) { throw new CustomException(identityResult.Errors.Aggregate("", (current, error) => current + error + "\n")); } }