/// <summary> /// This method updates the Person / Organisation information /// using contact service . /// </summary> /// <param name="logonId">User logon ID</param> /// <param name="person">Person information</param> /// <param name="contactType">Individual / Organisation</param> /// <param name="organisation">Organisation Information</param> /// <returns>Return Value</returns> public ReturnValue UpdateGeneralContact(Guid logonId, Person person, IRISLegal.IlbCommon.ContactType contactType, 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 case DataConstants.UserType.ThirdParty: switch (contactType) { case IRISLegal.IlbCommon.ContactType.Individual: if (!ApplicationSettings.Instance.IsUser(person.MemberId, DataConstants.DummyGuid)) throw new Exception("Access denied"); break; case IRISLegal.IlbCommon.ContactType.Organisation: if (!ApplicationSettings.Instance.IsUser(DataConstants.DummyGuid, organisation.OrganisationId)) throw new Exception("Access denied"); break; default: throw new Exception("Invalid contact type"); } break; case DataConstants.UserType.Client: switch (contactType) { case IRISLegal.IlbCommon.ContactType.Individual: if (!ApplicationSettings.Instance.IsUser(person.MemberId, DataConstants.DummyGuid)) throw new Exception("Access denied"); break; case IRISLegal.IlbCommon.ContactType.Organisation: if (!ApplicationSettings.Instance.IsUser(DataConstants.DummyGuid, organisation.OrganisationId)) throw new Exception("Access denied"); break; default: throw new Exception("Invalid contact type"); } break; default: throw new Exception("Access denied"); } SrvServiceContact serviceContactService = new SrvServiceContact(); SrvContact contactService = new SrvContact(); string errorMessage; string errorMessageWarning; contactService.ContactType = contactType; contactService.Load(person.MemberId); if (!contactService.ValidateId(out errorMessage, out errorMessageWarning)) { serviceContactService.Id = person.MemberId; serviceContactService.Load(); serviceContactService.Person.ForeName = person.ForeName; serviceContactService.Person.MaritalId = person.MaritalStatusId; serviceContactService.Person.PersonArmedForcesNo = person.ArmedForcesNo; serviceContactService.Person.PersonBirthName = person.BirthName; serviceContactService.Person.PersonDisability = person.DisabilityId; serviceContactService.Person.PersonDOB = person.DOB; serviceContactService.Person.PersonDOD = person.DOD; serviceContactService.Person.PersonEthnicityId = person.EthnicityId; serviceContactService.Person.PersonNINo = person.NINo; serviceContactService.Person.PersonOccupation = person.Occupation; serviceContactService.Person.PersonPlaceOfBirth = person.PlaceOfBirth; serviceContactService.Person.PersonPreviousName = person.PreviousName; serviceContactService.Person.PersonSalEnv = person.SalutationEnvelope; serviceContactService.Person.PersonSalLet = person.SalutationLettterFriendly; serviceContactService.Person.PersonSalletForm = person.SalutationLettterFormal; serviceContactService.Person.PersonSalutationlettterInformal = person.SalutationLettterInformal; serviceContactService.Person.Sex = person.Sex; serviceContactService.Person.Surname = person.Surname; serviceContactService.Person.Title = person.Title; returnValue.Success = serviceContactService.Save(out errorMessage); returnValue.Message = errorMessage; } else { if (contactService.ContactType == IRISLegal.IlbCommon.ContactType.Individual) { //Person Information for Individual contact contactService.Person.ForeName = person.ForeName; contactService.Person.MaritalId = person.MaritalStatusId; contactService.Person.PersonArmedForcesNo = person.ArmedForcesNo; contactService.Person.PersonBirthName = person.BirthName; contactService.Person.PersonDisability = person.DisabilityId; contactService.Person.PersonDOB = person.DOB; contactService.Person.PersonDOD = person.DOD; contactService.Person.PersonEthnicityId = person.EthnicityId; contactService.Person.PersonNINo = person.NINo; contactService.Person.PersonOccupation = person.Occupation; contactService.Person.PersonPlaceOfBirth = person.PlaceOfBirth; contactService.Person.PersonPreviousName = person.PreviousName; contactService.Person.PersonSalEnv = person.SalutationEnvelope; contactService.Person.PersonSalLet = person.SalutationLettterFriendly; contactService.Person.PersonSalletForm = person.SalutationLettterFormal; contactService.Person.PersonSalutationlettterInformal = person.SalutationLettterInformal; contactService.Person.Sex = person.Sex; contactService.Person.Surname = person.Surname; contactService.Person.Title = person.Title; } else { contactService.Load(organisation.OrganisationId); contactService.Organisation.IndustryId = organisation.IndustryId; contactService.Organisation.Name = organisation.Name; contactService.Organisation.RegisteredName = organisation.RegisteredName; contactService.Organisation.RegisteredNumber = organisation.RegisteredNo; contactService.Organisation.SubTypesId = organisation.SubTypeId; contactService.Organisation.VATNumber = organisation.VATNo; } returnValue.Success = contactService.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; }
public GeneralContactReturnValue GetGeneralContact(Guid logonId, Guid memberId, Guid organisationId) { GeneralContactReturnValue returnValue = new GeneralContactReturnValue(); 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"); } SrvContact srvContact = new SrvContact(); if (memberId != DataConstants.DummyGuid) { srvContact.ContactType = IRISLegal.IlbCommon.ContactType.Individual; srvContact.Id = memberId; } else { srvContact.ContactType = IRISLegal.IlbCommon.ContactType.Organisation; srvContact.Id = organisationId; } srvContact.Load(srvContact.Id); if (memberId != DataConstants.DummyGuid) { //General Info returnValue.Person = new Person(); returnValue.Person.Title = srvContact.Person.Title; returnValue.Person.ForeName = srvContact.Person.ForeName; returnValue.Person.Surname = srvContact.Person.Surname; returnValue.Person.MaritalStatusId = srvContact.Person.MaritalId; returnValue.Person.PreviousName = srvContact.Person.PersonPreviousName; returnValue.Person.Occupation = srvContact.Person.PersonOccupation; returnValue.Person.Sex = srvContact.Person.Sex; returnValue.Person.DOB = srvContact.Person.PersonDOB; returnValue.Person.DOD = srvContact.Person.PersonDOD; returnValue.Person.PlaceOfBirth = srvContact.Person.PersonPlaceOfBirth; returnValue.Person.BirthName = srvContact.Person.PersonBirthName; returnValue.CampaignId = srvContact.CampaignId; //Additional Info returnValue.Person.SalutationLettterFormal = srvContact.Person.PersonSalletForm; returnValue.Person.SalutationLettterInformal = srvContact.Person.PersonSalutationlettterInformal; returnValue.Person.SalutationLettterFriendly = srvContact.Person.PersonSalLet; returnValue.Person.SalutationEnvelope = srvContact.Person.PersonSalEnv; returnValue.Person.EthnicityId = srvContact.Person.PersonEthnicityId; returnValue.Person.IsInArmedForces = srvContact.Person.PersonInArmedForces; returnValue.Person.ArmedForcesNo = srvContact.Person.PersonArmedForcesNo; returnValue.Person.NINo = srvContact.Person.PersonNINo; returnValue.IsReceivingMarketingStatus = srvContact.IsReceivingMarketing; } else { returnValue.Organisation = new Organisation(); returnValue.Organisation.OrganisationId = srvContact.Organisation.OrganisationId; returnValue.Organisation.Name = srvContact.Organisation.Name; returnValue.Organisation.RegisteredName = srvContact.Organisation.RegisteredName; returnValue.Organisation.RegisteredNo = srvContact.Organisation.RegisteredNumber; returnValue.Organisation.VATNo = srvContact.Organisation.VATNumber; returnValue.Organisation.SubTypeId = srvContact.Organisation.SubTypesId; } } 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; }