/// <summary>
/// Copies the current object to a new instance
/// </summary>
/// <param name="deep">Copy members that refer to objects external to this class (not dependent)</param>
/// <param name="copiedObjects">Objects that should be reused</param>
/// <param name="asNew">Copy the current object as a new one, ready to be persisted, along all its members.</param>
/// <param name="reuseNestedObjects">If asNew is true, this flag if set, forces the reuse of all external objects.</param>
/// <param name="copy">Optional - An existing [DocumentAgreement] instance to use as the destination.</param>
/// <returns>A copy of the object</returns>
        public virtual DocumentAgreement Copy(bool deep = false, Hashtable copiedObjects = null, bool asNew = false, bool reuseNestedObjects = false, DocumentAgreement copy = null)
        {
            if (copiedObjects == null)
            {
                copiedObjects = new Hashtable();
            }
            if (copy == null && copiedObjects.Contains(this))
            {
                return((DocumentAgreement)copiedObjects[this]);
            }
            copy = copy ?? new DocumentAgreement();
            if (!asNew)
            {
                copy.TransientId = this.TransientId;
                copy.Id          = this.Id;
            }
            copy.SupplierDocument = this.SupplierDocument;
            copy.InvestorDocument = this.InvestorDocument;
            copy.AdminDocument    = this.AdminDocument;
            if (!copiedObjects.Contains(this))
            {
                copiedObjects.Add(this, copy);
            }
            if (deep && this.agreement != null)
            {
                if (!copiedObjects.Contains(this.agreement))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.Agreement = this.Agreement;
                    }
                    else if (asNew)
                    {
                        copy.Agreement = this.Agreement.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.agreement = this.agreement.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.Agreement = (Agreement)copiedObjects[this.Agreement];
                    }
                    else
                    {
                        copy.agreement = (Agreement)copiedObjects[this.Agreement];
                    }
                }
            }
            return(copy);
        }
/// <summary>
///     Returns true if self and the provided entity have the same Id values
///     and the Ids are not of the default Id value
/// </summary>
        protected bool HasSameNonDefaultIdAs(DocumentAgreement compareTo)
        {
            return(!this.IsTransient() && !compareTo.IsTransient() && this.Id.Equals(compareTo.Id));
        }
示例#3
0
        public void Agreement_persistence_test()
        {
            DateTime now = DateTime.Now;

            // Get datetime without milliseconds
            now = new DateTime(now.Ticks - (now.Ticks % TimeSpan.TicksPerSecond), now.Kind);
            var _agreement_investor_agreements = new DSS5_SupplyChainFinancialsOptimisation.BO.Investor
            {
                InvestorId           = 1174,
                PrimaryPhone         = "Investor_PrimaryPhone",
                SecondaryPhone       = "Investor_SecondaryPhone",
                Fax                  = "Investor_Fax",
                WebSite              = "Investor_WebSite",
                Company              = "Investor_Company",
                ContactPerson        = "Investor_ContactPerson",
                Logo                 = "Investor_Logo",
                SupervisingAuthority = "Investor_SupervisingAuthority",
                RegistrationNo       = "Investor_RegistrationNo",
                DomainFocus          = "Investor_DomainFocus",
                TurnOver             = 2222222222.22222M,
                VatNumber            = "Investor_VatNumber",
                AddressTwo           = "Investor_AddressTwo",
                AddressOne           = "Investor_AddressOne",
                ManagingDirector     = "Investor_ManagingDirector",
                TargetMarket         = "Investor_TargetMarket",
                CustomerSizeFrom     = "Investor_CustomerSizeFrom",
                CustomerSizeTo       = "Investor_CustomerSizeTo",
                LocalJurisdiction    = "Investor_LocalJurisdiction",
                CommercialRegNo      = "Investor_CommercialRegNo",
                OtherMinRequirements = "Investor_OtherMinRequirements",
                CRR                  = true,
                UploadCompliance     = "Investor_UploadCompliance",
                OtherMemberships     = "Investor_OtherMemberships",
                OtherDomainFocus     = "Investor_OtherDomainFocus",
                InvestorStatus       = "Investor_InvestorStatus",
                IAFC                 = true,
                Prefix               = "Investor_Prefix",
                UserName             = "******",
                PasswordHash         = "Investor_PasswordHash",
                SecurityStamp        = "Investor_SecurityStamp",
                EmailConfirmed       = true,
                LockoutEnabled       = true,
                PhoneNumberConfirmed = true,
                TwoFactorEnabled     = true,
                AccessFailedCount    = 3988,
                Name                 = "Investor_Name",
                Email                = "Investor_Email",
                PhoneNumber          = "Investor_PhoneNumber",
                LockoutEndDate       = now,
            };
            var _agreement_supplier_agreements = new DSS5_SupplyChainFinancialsOptimisation.BO.Supplier
            {
                SupplierId              = 4870,
                Company                 = "Supplier_Company",
                CompanyLogo             = "Supplier_CompanyLogo",
                Business                = "Supplier_Business",
                CurrentAmount           = "Supplier_CurrentAmount",
                AverageAmount           = "Supplier_AverageAmount",
                PercentageOfCreditNotes = "Supplier_PercentageOfCreditNotes",
                PrimaryPhone            = "Supplier_PrimaryPhone",
                SecondaryPhone          = "Supplier_SecondaryPhone",
                Fax                     = "Supplier_Fax",
                WebSite                 = "Supplier_WebSite",
                AcceptedPolicyTerms     = true,
                SupplierStatus          = "Supplier_SupplierStatus",
                DomainFocus             = "Supplier_DomainFocus",
                EvaluationResult        = "Supplier_EvaluationResult",
                EvaluationCountResult   = 1087,
                AnnualTurnover          = true,
                BEnvironment            = true,
                PTerms                  = true,
                Average                 = true,
                InvoiceValue            = true,
                EqRatio                 = true,
                Prefix                  = "Supplier_Prefix",
                VATNumber               = "Supplier_VATNumber",
                MarketSegment           = "Supplier_MarketSegment",
                AdditionalComments      = "Supplier_AdditionalComments",
                AdditionalCommentsStep2 = "Supplier_AdditionalCommentsStep2",
                AdditionalCommentsStep3 = "Supplier_AdditionalCommentsStep3",
                UserName                = "******",
                PasswordHash            = "Supplier_PasswordHash",
                SecurityStamp           = "Supplier_SecurityStamp",
                EmailConfirmed          = true,
                LockoutEnabled          = true,
                PhoneNumberConfirmed    = true,
                TwoFactorEnabled        = true,
                AccessFailedCount       = 1898,
                Name                    = "Supplier_Name",
                Email                   = "Supplier_Email",
                PhoneNumber             = "Supplier_PhoneNumber",
                LockoutEndDate          = now,
            };
            var _agreement_fundedtransactions_agreement = new DSS5_SupplyChainFinancialsOptimisation.BO.FundedTransaction
            {
                FundingPercentage = "FundedTransaction_FundingPercentage",
                TransactionStatus = "FundedTransaction_TransactionStatus",
            };
            var _agreement_fundedtransactions_agreement2 = new DSS5_SupplyChainFinancialsOptimisation.BO.FundedTransaction
            {
                FundingPercentage = "FundedTransaction_FundingPercentage",
                TransactionStatus = "FundedTransaction_TransactionStatus",
            };
            var _agreement_agreementstatus_agreement = new DSS5_SupplyChainFinancialsOptimisation.BO.AgreementStatus
            {
                Status      = "AgreementStatus_Status",
                DateOccured = now,
                ProvidedBy  = "AgreementStatus_ProvidedBy",
            };
            var _agreement_agreementstatus_agreement2 = new DSS5_SupplyChainFinancialsOptimisation.BO.AgreementStatus
            {
                Status      = "AgreementStatus_Status",
                DateOccured = now,
                ProvidedBy  = "AgreementStatus_ProvidedBy",
            };
            var _agreement_documentagreement_agreement = new DSS5_SupplyChainFinancialsOptimisation.BO.DocumentAgreement
            {
                SupplierDocument = "DocumentAgreement_SupplierDocument",
                InvestorDocument = "DocumentAgreement_InvestorDocument",
                AdminDocument    = "DocumentAgreement_AdminDocument",
            };
            var _agreement_commercialagreements_agreement = new DSS5_SupplyChainFinancialsOptimisation.BO.CommercialAgreement
            {
                ProductCategory = "CommercialAgreement_ProductCategory",
                PaymentTerms    = "CommercialAgreement_PaymentTerms",
            };
            var _agreement_commercialagreements_agreement2 = new DSS5_SupplyChainFinancialsOptimisation.BO.CommercialAgreement
            {
                ProductCategory = "CommercialAgreement_ProductCategory",
                PaymentTerms    = "CommercialAgreement_PaymentTerms",
            };

            new PersistenceSpecification <DSS5_SupplyChainFinancialsOptimisation.BO.Agreement>(Session)
            .CheckProperty(p => p.StartDate, now)
            .CheckProperty(p => p.EndDate, now)
            .CheckProperty(p => p.FundedRate, 222222.22M)
            .CheckProperty(p => p.FundedAmount, 222222.22M)
            .CheckProperty(p => p.InterestRate, 222222.22M)
            .CheckReference(p => p.Investor, _agreement_investor_agreements)
            .CheckReference(p => p.Supplier, _agreement_supplier_agreements)
            .CheckBag(p => p.FundedTransactions, (new List <DSS5_SupplyChainFinancialsOptimisation.BO.FundedTransaction>
            {
                _agreement_fundedtransactions_agreement,
                _agreement_fundedtransactions_agreement2
            }))
            .CheckBag(p => p.AgreementStatus, (new List <DSS5_SupplyChainFinancialsOptimisation.BO.AgreementStatus>
            {
                _agreement_agreementstatus_agreement,
                _agreement_agreementstatus_agreement2
            }))
            .CheckReference(p => p.DocumentAgreement, _agreement_documentagreement_agreement)
            .CheckBag(p => p.CommercialAgreements, (new List <DSS5_SupplyChainFinancialsOptimisation.BO.CommercialAgreement>
            {
                _agreement_commercialagreements_agreement,
                _agreement_commercialagreements_agreement2
            }))
            .VerifyTheMappings();
        }