/// <summary>
        /// Update an existing client organisation
        /// </summary>
        /// <param name="logonId">Logon id obtained when logging on to the logon service</param>
        /// <param name="organisation">Organisation details</param>
        /// <returns></returns>
        public ReturnValue UpdateClientOrganisation(Guid logonId, Organisation organisation)
        {
            ReturnValue returnValue = new ReturnValue();

            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:
                            if (!ApplicationSettings.Instance.IsUser(DataConstants.DummyGuid, organisation.OrganisationId))
                                throw new Exception("Access denied");
                            break;
                        case DataConstants.UserType.ThirdParty:
                            throw new Exception("Access denied");
                        default:
                            throw new Exception("Access denied");
                    }

                    // Later need to check permissions to see if they are allowed
                    // to update this client.

                    SrvOrganisation srvOrganisation = new SrvOrganisation();
                    srvOrganisation.Load(organisation.OrganisationId);

                    //Update the organisation details
                    srvOrganisation.Name = organisation.Name;
                    srvOrganisation.RegisteredName = organisation.RegisteredName;
                    srvOrganisation.RegisteredNumber = organisation.RegisteredNo;
                    srvOrganisation.VATNumber = organisation.VATNo;
                    srvOrganisation.SubTypesId = organisation.SubTypeId;

                    string errorMessage;
                    returnValue.Success = srvOrganisation.Save(out errorMessage);
                    if (!returnValue.Success)
                    {
                        throw new Exception(errorMessage);
                    }

                    //check if industry has been assigned and update the value
                    if (organisation.IndustryId != -1)
                    {
                        errorMessage = string.Empty;
                        SrvIndustry srvIndustry = new SrvIndustry();
                        srvIndustry.Id = organisation.IndustryId;
                        srvIndustry.MemberId = DataConstants.DummyGuid;
                        srvIndustry.OrganisationId = organisation.OrganisationId;
                        returnValue.Success = srvIndustry.Save(out errorMessage);
                    }
                    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;
        }
        /// <summary>
        /// Update an existing client
        /// </summary>
        /// <param name="logonId">Logon id obtained when logging on to the logon service</param>
        /// <param name="client">Client details</param>
        /// <param name="person"></param>
        /// <param name="organisation"></param>
        /// <returns></returns>
        public IRIS.Law.WebServiceInterfaces.ReturnValue UpdateClient(Guid logonId, Client client,
                                                        Person person, Organisation organisation)
        {
            ReturnValue returnValue = new ReturnValue();

            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:
                            if (!ApplicationSettings.Instance.IsUser(client.MemberId, client.OrganisationId))
                                throw new Exception("Access denied");
                            break;
                        case DataConstants.UserType.ThirdParty:
                            throw new Exception("Access denied");
                        default:
                            throw new Exception("Access denied");
                    }

                    SrvClient srvClient = new SrvClient();
                    srvClient.Load(client.MemberId, client.OrganisationId);

                    srvClient.MemberId = client.MemberId;
                    srvClient.OrganisationId = client.OrganisationId;
                    srvClient.ClientPartnerId = client.PartnerId;
                    srvClient.ClientBranch = client.Branch;
                    srvClient.ClientOpenDate = client.OpenDate;
                    srvClient.PreviousReference = client.PreviousReference;
                    srvClient.SourceId = client.BusinessSourceId;
                    srvClient.RatingId = client.RatingId;
                    srvClient.IsClientDoUpload = client.IsWebCaseTracking;
                    srvClient.ClientNetPassword = client.NetPassword;
                    srvClient.ClientGroup = client.Group;
                    srvClient.ClientHOUCN = client.HOUCN;
                    srvClient.ClientUCN = client.UCN;
                    srvClient.IsClientArchived = client.IsArchived;
                    srvClient.ClientType = client.Type;
                    srvClient.IsReceivingMarketing = client.IsReceivingMarketing;
                    srvClient.CliCashCollID = client.CashCollectionId;
                    srvClient.CliTotalLockup = client.TotalLockup;
                    srvClient.CampaignId = client.CampaignId;

                    //Since SrvClient saves the Person/Organisation details when we call save
                    //we need to pass the Person/Organisation ojects
                    srvClient.Person.PersonId = person.MemberId;
                    srvClient.Person.Title = person.Title;
                    srvClient.Person.ForeName = person.ForeName;
                    srvClient.Person.Surname = person.Surname;
                    srvClient.Person.MaritalId = person.MaritalStatusId;
                    srvClient.Person.PersonPreviousName = person.PreviousName;
                    srvClient.Person.PersonOccupation = person.Occupation;
                    srvClient.Person.Sex = person.Sex;
                    srvClient.Person.PersonDOB = person.DOB;
                    srvClient.Person.PersonDOD = person.DOD;
                    srvClient.Person.PersonPlaceOfBirth = person.PlaceOfBirth;
                    srvClient.Person.PersonBirthName = person.BirthName;
                    srvClient.Person.PersonSalletForm = person.SalutationLettterFormal;
                    srvClient.Person.PersonSalutationlettterInformal = person.SalutationLettterInformal;
                    srvClient.Person.PersonSalLet = person.SalutationLettterFriendly;
                    srvClient.Person.PersonSalEnv = person.SalutationEnvelope;
                    srvClient.Person.PersonEthnicityId = person.EthnicityId;
                    srvClient.Person.PersonDisability = person.DisabilityId;
                    srvClient.Person.PersonInArmedForces = person.IsInArmedForces;
                    srvClient.Person.PersonArmedForcesNo = person.ArmedForcesNo;
                    srvClient.Person.PersonNINo = person.NINo;

                    //Update the organisation details
                    srvClient.Organisation.OrganisationId = organisation.OrganisationId;
                    srvClient.Organisation.Name = organisation.Name;
                    srvClient.Organisation.RegisteredName = organisation.RegisteredName;
                    srvClient.Organisation.RegisteredNumber = organisation.RegisteredNo;
                    srvClient.Organisation.VATNumber = organisation.VATNo;
                    srvClient.Organisation.SubTypesId = organisation.SubTypeId;

                    string errorMessage;
                    returnValue.Success = srvClient.Save(out errorMessage);
                    if (!returnValue.Success)
                    {
                        throw new Exception(errorMessage);
                    }

                    if (client.MemberId == DataConstants.DummyGuid)
                    {
                        //check if industry has been assigned and update the value
                        if (organisation.IndustryId != 0)
                        {
                            errorMessage = string.Empty;
                            SrvIndustry srvIndustry = new SrvIndustry();
                            srvIndustry.Id = organisation.IndustryId;
                            srvIndustry.MemberId = DataConstants.DummyGuid;
                            srvIndustry.OrganisationId = organisation.OrganisationId;
                            returnValue.Success = srvIndustry.Save(out errorMessage);
                        }
                    }

                    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;
        }