public SspUserManagementServiceResponse CheckIfPortalAccountExist(Guid accountId)
        {
            var response = new SspUserManagementServiceResponse();

            try {
                var sspUserManagementHelper = new SspUserManagementServiceHelper(UserConnection);
                response.IsPortalAccountExists = sspUserManagementHelper.CheckIfAccountGroupExist(accountId);
            } catch (Exception ex) {
                response.Exception = ex;
            }
            return(response);
        }
        public SspLicenseResponse GetSspLicNames()
        {
            var response = new SspLicenseResponse();

            try {
                UserConnection.DBSecurityEngine.CheckCanManageSspUsers();
                var sspUserManagementHelper = new SspUserManagementServiceHelper(UserConnection);
                response.SspLicNames = sspUserManagementHelper.GetSspLicNames();
            } catch (Exception ex) {
                response.Exception = ex;
            }
            return(response);
        }
        public ConfigurationServiceResponse ChangeUserActivationStatus(Guid userId, bool isActive)
        {
            var response = new ConfigurationServiceResponse();

            try {
                UserConnection.DBSecurityEngine.CheckCanManageSspUsers();
                var sspUserManagementHelper = new SspUserManagementServiceHelper(UserConnection);
                sspUserManagementHelper.ChangeUserActivationStatus(userId, isActive);
            } catch (Exception ex) {
                response.Exception = ex;
            }
            return(response);
        }
        public ConfigurationServiceResponse ApplyOptionalFuncRolesForUsers(UserInRolePair[] usersInRoles)
        {
            var response = new ConfigurationServiceResponse();

            try {
                UserConnection.DBSecurityEngine.CheckCanManageSspUsers();
                var sspUserManagementHelper = new SspUserManagementServiceHelper(UserConnection);
                sspUserManagementHelper.ApplyOptionalFuncRolesForUsers(usersInRoles.ToList());
            } catch (Exception ex) {
                response.Exception = ex;
            }
            return(response);
        }
        public ContactsInviteServiceResponse InviteUsers(InviteServiceRequest request)
        {
            var response = new ContactsInviteServiceResponse();

            try {
                UserConnection.DBSecurityEngine.CheckCanManageSspUsers();
                var sspUserManagementHelper             = new SspUserManagementServiceHelper(UserConnection);
                IEnumerable <ISspUserInvitation> result = sspUserManagementHelper.InviteUsers(request);
                response.ContactInvites = MapContactsInvites(result);
            } catch (Exception ex) {
                response.Exception = ex;
            }
            return(response);
        }
        public SspUserManagementServiceRolesListResponse GetOptionalFuncRolesList(Guid sspAccountId)
        {
            var response = new SspUserManagementServiceRolesListResponse();

            try {
                UserConnection.DBSecurityEngine.CheckCanManageSspUsers();
                var sspUserManagementHelper = new SspUserManagementServiceHelper(UserConnection);
                var rolesList = sspUserManagementHelper.GetOptionalFuncRolesList(sspAccountId);
                response.RolesCollection = rolesList;
            } catch (Exception ex) {
                response.Exception = ex;
            }
            return(response);
        }
        public UserInRolePairServiceResponse GetEnabledFuncRolesForUser(Guid[] userIds)
        {
            var response = new UserInRolePairServiceResponse {
                UsersInRoles = new List <UserInRolePair>()
            };

            try {
                UserConnection.DBSecurityEngine.CheckCanManageSspUsers();
                var sspUserManagementHelper = new SspUserManagementServiceHelper(UserConnection);
                response.UsersInRoles = sspUserManagementHelper.GetEnabledFuncRolesForUser(userIds.ToList()).ToList();
            } catch (Exception ex) {
                response.Exception = ex;
            }
            return(response);
        }
        public SspUserManagementServiceSspAccountInfo GetSspAccountInfo()
        {
            var response = new SspUserManagementServiceSspAccountInfo();

            try {
                UserConnection.DBSecurityEngine.CheckCanManageSspUsers();
                var sspUserManagementHelper = new SspUserManagementServiceHelper(UserConnection);
                var sspAccountInfo          = sspUserManagementHelper.GetSspAccountInfo(UserConnection.CurrentUser.Id);
                response.SspAccountId          = (Guid)sspAccountInfo["PortalAccountId"];
                response.SspAccountAdminUnitId = (Guid)sspAccountInfo["SspAccountAdminUnitId"];
            } catch (Exception ex) {
                response.Exception = ex;
            }
            return(response);
        }
        public string GetDefaultSspLicName()
        {
            var sspUserManagementHelper = new SspUserManagementServiceHelper(UserConnection);

            return(sspUserManagementHelper.GetDefaultSspLicName());
        }