/// <summary> /// This method adds the Person, Address and Additional Address information /// using contact service to create a general contact. /// </summary> /// <param name="logonId">User logon ID</param> /// <param name="contactAddress">Address information for contact</param> /// <param name="person">Person information</param> /// <param name="additionalElement">Additional Element</param> /// <param name="contactType">Individual / Organisation</param> /// <param name="organisation">Organisation Information</param> /// <param name="conflictNoteSummary">The conflict note summary.</param> /// <param name="conflictNoteContent">Content of the conflict note.</param> /// <returns>Return Value</returns> public ReturnValue SaveGeneralContact(Guid logonId, Address contactAddress, Person person, AdditionalAddressElement[] additionalElement, IRISLegal.IlbCommon.ContactType contactType, Organisation organisation, string conflictNoteSummary, string conflictNoteContent) { 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: case DataConstants.UserType.ThirdParty: if (!ApplicationSettings.Instance.IsUser(additionalElement[0].MemberId, additionalElement[0].OrganisationId)) throw new Exception("Access denied"); break; default: throw new Exception("Access denied"); } SrvContact contactService = new SrvContact(); SrvAddress srvAddress = new SrvAddress(); srvAddress.AddressTypeId = Convert.ToInt32(DataConstants.SystemAddressTypes.Main); srvAddress.AddressStreetNumber = contactAddress.StreetNumber; srvAddress.AddressPostCode = contactAddress.PostCode; srvAddress.AddressHouseName = contactAddress.HouseName; srvAddress.AddressLine1 = contactAddress.Line1; srvAddress.AddressLine2 = contactAddress.Line2; srvAddress.AddressLine3 = contactAddress.Line3; srvAddress.AddressTown = contactAddress.Town; srvAddress.AddressCounty = contactAddress.County; srvAddress.AddressCountry = contactAddress.Country; srvAddress.AddressDXTown = contactAddress.DXTown; srvAddress.AddressDXNumber = contactAddress.DXNumber; srvAddress.IsMailingAddress = contactAddress.IsMailingAddress; srvAddress.IsBillingAddress = contactAddress.IsBillingAddress; srvAddress.AddressOrgName = contactAddress.OrganisationName; srvAddress.AddressComment = contactAddress.Comment; srvAddress.AddressDepartment = contactAddress.Department; srvAddress.AddressPostBox = contactAddress.PostBox; srvAddress.AddressSubBuilding = contactAddress.SubBuilding; srvAddress.AddressStreetNumber = contactAddress.StreetNumber; srvAddress.AddressDependantLocality = contactAddress.DependantLocality; srvAddress.AddressLastVerified = contactAddress.LastVerified; // Save Additional Address Info to Address Object if (additionalElement != null) { for (int i = 0; i <= 9; i++) { srvAddress.AdditionalInfoElements[i].AddressElementText = additionalElement[i].ElementText; } } contactService.Addresses.Add(srvAddress); contactService.ContactType = contactType; if (contactService.ContactType == IRISLegal.IlbCommon.ContactType.Individual) { //Person Information for Individual contact contactService.Person.Surname = person.Surname; contactService.Person.ForeName = person.ForeName; contactService.Person.Title = person.Title; } else { contactService.Organisation.Name = organisation.Name; } contactService.ConflictNoteSummary = conflictNoteSummary; contactService.ConflictNoteContent = conflictNoteContent; string errorMessage; 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; }
/// <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; }