/// <summary>
        /// 
        /// </summary>
        /// <param name="logonId"></param>
        /// <param name="criteria"></param>
        /// <returns></returns>
        public WorkTypeSearchReturnValue GetValuesOnWorkTypeSelected(Guid logonId, WorkTypeSearchCriteria criteria)
        {
            WorkTypeSearchReturnValue returnValue = new WorkTypeSearchReturnValue();
            string errorMessage = string.Empty;
            string warningMessage = string.Empty;
            bool isValid = false;

            try
            {
                Host.LoadLoggedOnUser(logonId);
                try
                {
                    Functions.RestrictRekoopIntegrationUser(UserInformation.Instance.DbUid);
                    switch (UserInformation.Instance.UserType)
                    {
                        case DataConstants.UserType.Staff:
                        case DataConstants.UserType.Client:
                        case DataConstants.UserType.ThirdParty:
                            // Can do everything
                            break;
                        default:
                            throw new Exception("Access denied");
                    }

                    // Create the dataset
                    SrvMatter serviceMatter = new SrvMatter();
                    //Set the client id and call the  client validation method which will set the client ref
                    //Cli ref is required to get the ucn and houcn values which are set in SetDefaultsOnWorkType
                    serviceMatter.ClientId = criteria.ClientId;
                    serviceMatter.ValidateClientId(out errorMessage, out warningMessage);
                    serviceMatter.CurrentWorkTypeId = criteria.Id;
                    isValid = serviceMatter.ValidateCurrentWorkTypeId(out errorMessage, out warningMessage);

                    // TODO: Does not use the criteria: FilterString, OrganisationID, DepartmentId, DepartmentNo, IsPrivateClient, MatterTypeId

                    if (isValid)
                    {
                        serviceMatter.SetDefaultsOnWorkType();
                        returnValue.IsPublicFunded = serviceMatter.IsPublicFunding;
                        returnValue.DisbLimit = serviceMatter.WorkTypeDisbLimit;
                        returnValue.OverallLimit = serviceMatter.WorkTypeOverallLimit;
                        returnValue.Quote = serviceMatter.WorkTypeQuote;
                        returnValue.TimeLimit = serviceMatter.WorkTypeTimeLimit;
                        returnValue.WipLimit = serviceMatter.WorkTypeWipLimit;
                        returnValue.ChargeRateDescriptionId = serviceMatter.ChargeDescriptionId;
                        returnValue.Franchised = serviceMatter.WorkCategoryFranchised;
                        returnValue.WorkCategoryUFN = serviceMatter.WorkCategoryUFN;
                        returnValue.ClientHOUCN = serviceMatter.ClientHOUCN;
                        returnValue.ClientUCN = serviceMatter.ClientUCN;
                    }
                    else
                    {
                        returnValue.Success = false;
                        returnValue.Message = errorMessage;
                    }

                }
                finally
                {
                    Host.UnloadLoggedOnUser();
                }
            }
            catch (System.Data.SqlClient.SqlException)
            {
                returnValue.Success = false;
                returnValue.Message = Functions.SQLErrorMessage;
            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Message = ex.Message;
            }
            return returnValue;
        }
        /// <summary>
        /// Gets the client type id and the default branch.
        /// </summary>
        /// <param name="logonId">The logon id.</param>
        /// <param name="clientId">The client id.</param>
        /// <param name="isMember">if set to <c>true</c> [is member].</param>
        /// <returns></returns>
        public ClientReturnValue GetClientDefaults(Guid logonId, Guid clientId)
        {
            ClientReturnValue returnValue = new ClientReturnValue();

            try
            {
                // Get the logged on user from the current logons and add their
                // ApplicationSettings the list of concurrent sessions.
                Host.LoadLoggedOnUser(logonId);

                try
                {
                    Functions.RestrictRekoopIntegrationUser(UserInformation.Instance.DbUid);
                    switch (UserInformation.Instance.UserType)
                    {
                        case DataConstants.UserType.Staff:
                            // Can do everything
                            break;
                        case DataConstants.UserType.Client:
                        case DataConstants.UserType.ThirdParty:
                            throw new Exception("Access denied");
                        default:
                            throw new Exception("Access denied");
                    }

                    string errorMessage = string.Empty;
                    string warningMessage = string.Empty;
                    SrvMatter srvMatter = new SrvMatter();
                    srvMatter.ClientId = clientId;
                    bool success = srvMatter.ValidateClientId(out errorMessage, out warningMessage);
                    if (success)
                    {
                        returnValue.Client = new Client();
                        returnValue.Client.TypeId = srvMatter.ClientTypeId;
                        returnValue.Client.Branch = srvMatter.DefaultBranchId;
                    }
                    else
                    {
                        returnValue.Success = false;
                        returnValue.Message = errorMessage;
                    }
                }
                finally
                {
                    // Remove the logged on user's ApplicationSettings from the
                    // list of concurrent sessions
                    Host.UnloadLoggedOnUser();
                }
            }
            catch (System.Data.SqlClient.SqlException)
            {
                returnValue.Success = false;
                returnValue.Message = Functions.SQLErrorMessage;
            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Message = ex.Message;
            }

            return returnValue;
        }