public static CustomerDetails GetCustomerDetailInfo(int Id)
        {
            CustomerDetails detail = new CustomerDetails(Id);

            detail.Contacts = new ContactsCollection();
            detail.Contacts.LoadByCustClientID(Id);
            detail.CustomerNotes = new CustomerNotesCollection();
            detail.CustomerNotes.LoadByCustClientID(Id);
            detail.User = new Users();
            detail.User.LoadByClientID(Id);
            detail.Registration = new Registration(detail.User.RegistrationID);
            detail.Aircrafts    = new AircraftsCollection();
            detail.Aircrafts.LoadByCustClientID(Id);
            detail.CustomerPriceMargin = new CustomerPriceMargins();
            detail.CustomerPriceMargin.LoadByCustClientID(Id);
            detail.CustomerAccountingInfo = new CustomerAccountingInfo();
            detail.CustomerAccountingInfo.LoadInfoByAdminAndCustClientID(detail.AdminClientID, detail.CustClientID);
            detail.CustomFields = new CustomerDetailsCustomFieldsCollection();
            detail.CustomFields.GetCustomFields(detail.AdminClientID, detail.CustClientID);
            var partnerService = new PartnerServiceIntegrations();

            detail.Integration = partnerService.GetByClientID(Id, detail.AdminClientID);
            if (detail.Integration == null)
            {
                detail.Integration = new PartnerServiceIntegration();
            }
            return(detail);
        }
        public void AddGUID(ref PartnerServiceIntegration serviceIntegration)
        {
            if (serviceIntegration.AccountNumber == Guid.Empty)
            {
                var partnerService = new PartnerServiceIntegrations();
                var Integration    = partnerService.GetByClientID(serviceIntegration.ClientID, serviceIntegration.AdminClientID);
                if (Integration != null)
                {
                    serviceIntegration.AccountNumber = Integration.AccountNumber;
                    serviceIntegration.Id            = Integration.Id;
                }
            }

            if (serviceIntegration.AccountNumber == Guid.Empty)
            {
                serviceIntegration.AccountNumber = Guid.NewGuid();

                if (serviceIntegration.AdminClientID == 0)
                {
                    serviceIntegration.AdminClientID = Users.CurrentUser.ClientID;
                }

                //Send an email notification to [email protected] containing the customer client's name
                EmailRoutingCollection emailsCollection = EmailRouting.GetEmailsByAdminClient(serviceIntegration.AdminClientID);
                EmailRouting           emailRouting     = new EmailRouting();
                foreach (EmailRouting emails in emailsCollection)
                {
                    if (emails.EmailType == "New Client Activated")
                    {
                        emailRouting = emails;
                        break;
                    }
                }

                Clients client = new Clients(serviceIntegration.ClientID);

                MailMessage mailMessage = new MailMessage();
                mailMessage.From = new MailAddress(emailRouting.FromEmail);
                mailMessage.To.Add(new MailAddress("*****@*****.**"));

                mailMessage.IsBodyHtml = true;
                mailMessage.Priority   = MailPriority.Normal;
                mailMessage.Body       = client.Name + " was activated from " + Users.CurrentUser.Client.Name +
                                         ". Their account number is: " + serviceIntegration.AccountNumber.ToString();

                try
                {
                    Degatech.Utilities.Data.Utilities.SendEmail(mailMessage);
                }
                catch (Exception ex)
                {
                }
            }
        }