Example #1
0
        private static ICustomerAccount processAanvraag(IDalSession session, IEGAccount acc)
        {
            IEGAanvraag aacReq = acc.AccountRequest;

            //Most Important ... Manage Contact First
            IContact primary = null;
            IContact secondary = null;
            DateTime creationdate = session.GetServerTime();

            if (aacReq.IsPersonalAccount)
            {
                primary = CreateContactPerson(session, aacReq.SOFI,
                                                        aacReq.Voorletters,
                                                        aacReq.Tussenvoegsels,
                                                        aacReq.Naam,
                                                        aacReq.PostalAddress,
                                                        aacReq.ResidentialAddress1,
                                                        aacReq.ContactDetails1,
                                                        aacReq.PrimaryGender,
                                                        aacReq.Nationality1,
                                                        aacReq.Identification1,
                                                        aacReq.Geboortedatum,
                                                        acc.AssetManager,
                                                        creationdate);
                if (aacReq.IsDualAccount)
                    secondary = CreateContactPerson(session, aacReq.PSOFI,
                                                        aacReq.PVoorletters,
                                                        aacReq.PTussenvoegsels,
                                                        aacReq.PNaam,
                                                        aacReq.PostalAddress,
                                                        aacReq.ResidentialAddress2,
                                                        aacReq.ContactDetails2,
                                                        aacReq.SecondaryGender,
                                                        aacReq.Nationality2,
                                                        aacReq.Identification2,
                                                        aacReq.PGeboortedatum,
                                                        acc.AssetManager,
                                                        creationdate);
            }
            else
            {
                primary = CreateContactCompany(session, aacReq.KVK,
                                                        aacReq.BNaam,
                                                        aacReq.PostalAddress,
                                                        aacReq.BAddress,
                                                        aacReq.BContactDetails,
                                                        aacReq.DatumOprichting,
                                                        acc.AssetManager,
                                                        creationdate);

                // contact person on company
                secondary = CreateContactPerson(session, aacReq.SOFI,
                                                        aacReq.Voorletters,
                                                        aacReq.Tussenvoegsels,
                                                        aacReq.Naam,
                                                        aacReq.PostalAddress,
                                                        aacReq.ResidentialAddress1,
                                                        aacReq.ContactDetails1,
                                                        aacReq.PrimaryGender,
                                                        aacReq.Nationality1,
                                                        aacReq.Identification1,
                                                        aacReq.Geboortedatum,
                                                        acc.AssetManager,
                                                        creationdate);

            }
            ICounterAccount counterAccount = CreateCounterAccount(session, primary, acc);

            // store contacts
            B4F.TotalGiro.CRM.ContactMapper.Update(session, primary);
            if (secondary != null) B4F.TotalGiro.CRM.ContactMapper.Update(session, secondary);

            // check for contactperson on company
            if (!aacReq.IsPersonalAccount && secondary != null)
            {
                ICompanyContactPerson compContactPerson = new CompanyContactPerson((IContactPerson)secondary, (IContactCompany)primary);

                if (!((IContactCompany)primary).CompanyContacts.Contains(compContactPerson))
                {
                    ((IContactCompany)primary).CompanyContacts.Add(compContactPerson);
                    ContactMapper.Update(session, primary);
                }
            }

            // get the family
            IAccountFamily family = AccountFamilyMapper.GetAccountFamily(session, acc.NummerPreFix);
            ICustomerAccount newAcc = CreateAccount(acc, creationdate, family);

            //add as accountHolders
            newAcc.AccountHolders.Add(new AccountHolder(newAcc, primary));
            newAcc.AccountHolders.SetPrimaryAccountHolder(primary);

            if (secondary != null)
            {
                newAcc.AccountHolders.Add(new AccountHolder(newAcc, secondary));
                secondary.CounterAccounts.Add(newAcc.CounterAccount);
            }

            //Add CounterAccount
            newAcc.CounterAccount = counterAccount;

            //set the account on the aanvraag
            acc.TGAccount = newAcc;

            //update all
            B4F.TotalGiro.Accounts.AccountMapper.Update(session, newAcc);

            //Set the Model History
            IInternalEmployeeLogin employee = (IInternalEmployeeLogin)LoginMapper.GetCurrentLogin(session);
            IModelHistory item = new ModelHistory(newAcc, newAcc.Lifecycle, newAcc.ModelPortfolio, newAcc.IsExecOnlyCustomer, newAcc.EmployerRelationship, employee, creationdate);
            newAcc.ModelPortfolioChanges.Add(item);
            B4F.TotalGiro.Accounts.AccountMapper.Update(session, newAcc);

            return newAcc;
        }