private void ValidaIntegraPontua(Entity entityTargetUpdate, ContatoService ContatoService, Contato contatoUpdate, ref IPluginExecutionContext Context, IOrganizationService service) { ContatoService.ValidarDadosContato(contatoUpdate); var contato = ContatoService.BuscaContato(contatoUpdate.Id); if (contato != null) { if (contato.AssociadoA != null) { //Pode estar vinculado à contatos var contaAssociada = new Domain.Servicos.ContaService(Context.OrganizationName, Context.IsExecutingOffline, service).BuscaConta(contato.AssociadoA.Id); if (contaAssociada != null) { var IntegraPontua = (new Domain.Servicos.BeneficioDoCanalService(Context.OrganizationName, Context.IsExecutingOffline, service).validaIntegraPontuaFielo(contaAssociada, null)); entityTargetUpdate.Attributes["itbc_integraintelbraspontua"] = IntegraPontua; } } else if (entityTargetUpdate.Attributes.Contains("parentcustomerid")) { if (entityTargetUpdate.Attributes["parentcustomerid"] != null) { var contaAssociada = new Domain.Servicos.ContaService(Context.OrganizationName, Context.IsExecutingOffline, service).BuscaConta(((EntityReference)entityTargetUpdate.Attributes["parentcustomerid"]).Id); if (contaAssociada != null) { var IntegraPontua = (new Domain.Servicos.BeneficioDoCanalService(Context.OrganizationName, Context.IsExecutingOffline, service).validaIntegraPontuaFielo(contaAssociada, null)); entityTargetUpdate.Attributes["itbc_integraintelbraspontua"] = IntegraPontua; } } else { entityTargetUpdate.Attributes["itbc_integraintelbraspontua"] = false; } } else { entityTargetUpdate.Attributes["itbc_integraintelbraspontua"] = false; } } }