コード例 #1
0
        public override void Execute()
        {
            DateTime now = DateTime.UtcNow;
            var      con = DB.GetPersistent();

            con.BeginTransaction();

            try {
                var dbContact = new I_InvestorContact {
                    InvestorContactID = this.contact.InvestorContactID,
                    Email             = this.contact.Email,
                    InvestorID        = this.contact.InvestorID,
                    Comment           = this.contact.Comment,
                    LastName          = this.contact.LastName,
                    Mobile            = this.contact.Mobile,
                    OfficePhone       = this.contact.OfficePhone,
                    PersonalName      = this.contact.PersonalName,
                    Role      = this.contact.Role,
                    IsPrimary = this.contact.IsPrimary,
                    Timestamp = now,
                    IsActive  = this.contact.IsActive,
                };

                if (this.contact.InvestorContactID == 0)
                {
                    var userSingup = new SignupInvestorMultiOrigin(contact.Email);
                    userSingup.Transaction = con;
                    userSingup.Execute();

                    // The .Execute() above completes successfully if and only if no error detected and .UserID > 0.

                    dbContact.InvestorContactID = userSingup.UserID;

                    DB.ExecuteNonQuery(con, "I_InvestorContactSave", CommandSpecies.StoredProcedure,
                                       DB.CreateTableParameter <I_InvestorContact>("Tbl", new List <I_InvestorContact> {
                        dbContact
                    })
                                       );
                }
                else
                {
                    DB.ExecuteNonQuery(con, "I_InvestorContactUpdate", CommandSpecies.StoredProcedure,
                                       DB.CreateTableParameter <I_InvestorContact>("Tbl", new List <I_InvestorContact> {
                        dbContact
                    })
                                       );
                }                //if
            } catch (Exception ex) {
                Log.Warn(ex, "Failed to save investor {0} contact to DB", this.contact.InvestorID);
                con.Rollback();
                Result = false;
                throw;
            }            //try

            con.Commit();
            Result = true;
            Log.Info("Save investor {0} contact data into DB complete.", this.contact.InvestorID);
        }        //Execute
コード例 #2
0
ファイル: CreateInvestor.cs プロジェクト: vijayamazon/ezbob
        public override void Execute()
        {
            DateTime now = DateTime.UtcNow;
            var      con = DB.GetPersistent();

            con.BeginTransaction();

            try {
                InvestorID = DB.ExecuteScalar <int>(con, "I_InvestorSave", CommandSpecies.StoredProcedure,
                                                    DB.CreateTableParameter <I_Investor>("Tbl",
                                                                                         new List <I_Investor> {
                    new I_Investor {
                        Name                        = this.investor.Name,
                        InvestorTypeID              = this.investor.InvestorType.InvestorTypeID,
                        IsActive                    = false,
                        Timestamp                   = now,
                        MonthlyFundingCapital       = this.investor.MonthlyFundingCapital,
                        FundingLimitForNotification = this.investor.FundingLimitForNotification,
                        FundsTransferDate           = this.investor.FundsTransferDate,
                    }
                })
                                                    );

                if (InvestorID == 0)
                {
                    throw new StrategyWarning(this, "Failed creating investor");
                }

                foreach (var contact in this.contacts)
                {
                    var userSingup = new SignupInvestorMultiOrigin(contact.Email);
                    userSingup.Transaction = con;
                    userSingup.Execute();

                    // The .Execute() above completes successfully if and only if no error detected and .UserID > 0.

                    var dbContact = new I_InvestorContact {
                        InvestorContactID = userSingup.UserID,
                        Email             = contact.Email,
                        InvestorID        = InvestorID,
                        Comment           = contact.Comment,
                        LastName          = contact.LastName,
                        Mobile            = contact.Mobile,
                        OfficePhone       = contact.OfficePhone,
                        PersonalName      = contact.PersonalName,
                        Role      = contact.Role,
                        IsPrimary = contact.IsPrimary,
                        Timestamp = now,
                        IsActive  = true,
                    };

                    int contactsCount = DB.ExecuteScalar <int>(con, "I_InvestorContactSave", CommandSpecies.StoredProcedure,
                                                               DB.CreateTableParameter <I_InvestorContact>("Tbl", new List <I_InvestorContact> {
                        dbContact
                    }));

                    if (contactsCount != 1)
                    {
                        throw new StrategyWarning(this, "Failed creating investor contact");
                    }
                }

                var dbBanks = new List <I_InvestorBankAccount>();
                foreach (var bank in this.banks)
                {
                    dbBanks.Add(new I_InvestorBankAccount {
                        IsActive              = true,
                        Timestamp             = now,
                        BankAccountNumber     = bank.BankAccountNumber,
                        BankAccountName       = bank.BankAccountName,
                        BankBranchName        = bank.BankBranchName,
                        BankBranchNumber      = bank.BankBranchNumber,
                        BankCode              = bank.BankCode,
                        BankCountryID         = bank.BankCountryID,
                        BankName              = bank.BankName,
                        InvestorAccountTypeID = bank.AccountType.InvestorAccountTypeID,
                        InvestorBankAccountID = bank.InvestorBankAccountID,
                        RepaymentKey          = bank.RepaymentKey,
                        UserID     = this.underwriterID,
                        InvestorID = InvestorID
                    });
                }

                DB.ExecuteNonQuery(con, "I_InvestorBankAccountSave", CommandSpecies.StoredProcedure,
                                   DB.CreateTableParameter <I_InvestorBankAccount>("Tbl", dbBanks)
                                   );
            } catch (Exception ex) {
                Log.Warn(ex, "Failed to save investor to DB");
                con.Rollback();
                Result = false;
                throw;
            }

            con.Commit();
            Result = true;
            Log.Info("Save investor data into DB complete.");
        }        //Execute