コード例 #1
0
 ///
 /// Insert Duplicate Records
 ///
 public void SaveDuplicateLoan(DuplicateLoan model)
 {
     using (LoanPriceEntities context = new LoanPriceEntities())
     {
         if (model.ID > 0)
         {
             context.AddObject("DuplicateLoans", model);
         }
         else
         {
             context.AddToDuplicateLoans(model);
         }
         context.SaveChanges();
     }
 }
コード例 #2
0
        public void EditLoan(Loans loan, int loanID, int type)
        {
            try
            {
                using (LoanPriceEntities context = new LoanPriceEntities())
                {
                    Loans oldLoan = context.Loans.FirstOrDefault(c => c.ID == loanID);
                    oldLoan.CodeName        = loan.CodeName;
                    oldLoan.Borrower        = loan.Borrower;
                    oldLoan.Sector          = loan.Sector;
                    oldLoan.Signing_Date    = loan.Signing_Date;
                    oldLoan.Maturity_Date   = loan.Maturity_Date;
                    oldLoan.FixedOrFloating = loan.FixedOrFloating;
                    oldLoan.Margin          = loan.Margin;
                    oldLoan.Currency        = loan.Currency;
                    oldLoan.PP              = loan.PP;
                    oldLoan.CreditRating    = loan.CreditRating;
                    oldLoan.Country         = loan.Country;
                    oldLoan.CouponFrequency = loan.CouponFrequency;
                    oldLoan.FacilitySize    = loan.FacilitySize;
                    oldLoan.Bilateral       = loan.Bilateral;
                    oldLoan.Amortizing      = loan.Amortizing;

                    oldLoan.AmortisationsStartPoint = loan.AmortisationsStartPoint;
                    oldLoan.CouponDate            = loan.CouponDate;
                    oldLoan.Notional              = loan.Notional;
                    oldLoan.NoOfAmortisationPoint = loan.NoOfAmortisationPoint;

                    oldLoan.CreditRatingFitch = loan.CreditRatingFitch;
                    oldLoan.CreditRatingING   = loan.CreditRatingING;
                    oldLoan.CreditRatingModys = loan.CreditRatingModys;
                    oldLoan.CreditRatingSPs   = loan.CreditRatingSPs;
                    oldLoan.StructureID       = loan.StructureID;

                    oldLoan.LastEdited = loan.LastEdited;
                    oldLoan.CreatedBy  = loan.CreatedBy;

                    oldLoan.SummitCreditEntity = loan.SummitCreditEntity;
                    oldLoan.Grid     = loan.Grid;
                    oldLoan.Gurantor = loan.Gurantor;
                    context.SaveChanges();

                    //if type == 1 then do not add to DuplicateLoan
                    if (CheckForLoanCode(loan.CodeName, loanID) && type != 1)
                    {
                        DuplicateLoan duplicateLoan = new DuplicateLoan();
                        duplicateLoan.CodeName        = loan.CodeName;
                        duplicateLoan.Borrower        = loan.Borrower;
                        duplicateLoan.Sector          = loan.Sector;
                        duplicateLoan.Signing_Date    = loan.Signing_Date;
                        duplicateLoan.Maturity_Date   = loan.Maturity_Date;
                        duplicateLoan.FixedOrFloating = loan.FixedOrFloating;
                        duplicateLoan.Margin          = loan.Margin;
                        duplicateLoan.Currency        = loan.Currency;

                        duplicateLoan.Country         = loan.Country;
                        duplicateLoan.CouponFrequency = loan.CouponFrequency;
                        duplicateLoan.FacilitySize    = loan.FacilitySize;
                        duplicateLoan.Bilateral       = loan.Bilateral;
                        duplicateLoan.Amortizing      = loan.Amortizing;

                        duplicateLoan.AmortisationsStartPoint = loan.AmortisationsStartPoint;
                        duplicateLoan.CouponDate            = loan.CouponDate;
                        duplicateLoan.Notional              = loan.Notional;
                        duplicateLoan.NoOfAmortisationPoint = loan.NoOfAmortisationPoint;

                        context.AddToDuplicateLoans(duplicateLoan);
                        context.SaveChanges();
                    }
                }
            }
            catch (Exception)
            {
            }
        }
コード例 #3
0
        public string AddImportedLoans(Loans item)
        {
            LogsBLL logBL = new LogsBLL();
            string  str   = "";

            try
            {
                using (LoanPriceEntities context = new LoanPriceEntities())
                {
                    string codeName = item.CodeName;
                    if (CheckForLoanCode(item.CodeName))
                    {
                        context.AddToLoans(item);
                        context.SaveChanges();
                        //item = GetLoanByCode(codeName);

                        LoanScheduleBL loanScheduleBL = new LoanScheduleBL();
                        string         couponDT       = item.CouponDate.ToString();
                        DateTime       cpnDT;
                        if (couponDT == string.Empty)
                        {
                            cpnDT = AddBusinessDays(DateTime.Now, 10);
                        }
                        else
                        {
                            cpnDT = Convert.ToDateTime(item.CouponDate);
                        }
                        DateTime  tradeDate  = DateTime.Now;
                        DataTable dtSchedule = loanScheduleBL.GenerateTable(15, Convert.ToInt16(item.NoOfAmortisationPoint), Convert.ToDateTime(item.AmortisationsStartPoint), item.CouponFrequency.ToString(), item.Notional.ToString(), Convert.ToDateTime(item.Maturity_Date), Convert.ToDateTime(item.CouponDate), Convert.ToDecimal(item.Margin), Convert.ToString(item.Currency), Convert.ToDateTime(tradeDate), AddBusinessDays(Convert.ToDateTime(tradeDate), 10));
                        if (dtSchedule != null)
                        {
                            try
                            {
                                foreach (DataRow dr in dtSchedule.Rows)
                                {
                                    LoanSchedule loanSchedule = new LoanSchedule();
                                    loanSchedule.LoanID            = item.ID;
                                    loanSchedule.StartDate         = Convert.ToDateTime(dr["StartDate"]);
                                    loanSchedule.EndDate           = Convert.ToDateTime(dr["EndDate"]);
                                    loanSchedule.Notation          = Convert.ToDecimal(dr["Notation"]);
                                    loanSchedule.CoupFrac          = Convert.ToDecimal(dr["CoupFrac"]);
                                    loanSchedule.Amortisation      = Convert.ToDecimal(dr["Amortisation"]);
                                    loanSchedule.Factor            = Convert.ToDecimal(dr["Factor"]);
                                    loanSchedule.CouponPaymentDate = Convert.ToDateTime(dr["CouponPaymentDate"]);
                                    loanSchedule.Spread            = Convert.ToDecimal(dr["Spread"]);
                                    loanSchedule.RiskFreeDP1       = Convert.ToDecimal(dr["RiskFreeDP1"]);
                                    loanSchedule.RiskFreeDP2       = Convert.ToDecimal(dr["RiskFreeDP2"]);
                                    loanSchedule.FloatingRate      = Convert.ToDecimal(dr["FloatingRate"]);
                                    loanSchedule.AllInRate         = Convert.ToDecimal(dr["AllInRate"]);
                                    loanSchedule.Interest          = Convert.ToDecimal(dr["Interest"]);
                                    loanSchedule.Days            = Convert.ToInt16(dr["Days"]);
                                    loanSchedule.AmortisationInt = Convert.ToDecimal(dr["AmortisationInt"]);
                                    loanScheduleBL.SaveLoanSchedule(loanSchedule);
                                }
                            }
                            catch (Exception ex)
                            {
                                str = ex.Message;
                                //  str = ex.Message;
                            }
                        }
                    }
                    else
                    {
                        DuplicateLoan loan = new DuplicateLoan();
                        loan.CodeName        = item.CodeName;
                        loan.Borrower        = item.Borrower;
                        loan.Country         = item.Country;
                        loan.Sector          = item.Sector;
                        loan.Maturity_Date   = item.Maturity_Date;
                        loan.Signing_Date    = item.Signing_Date;
                        loan.FixedOrFloating = item.FixedOrFloating;
                        loan.Margin          = item.Margin;
                        loan.Currency        = item.Currency;
                        loan.CouponFrequency = item.CouponFrequency;
                        loan.FacilitySize    = item.FacilitySize;
                        loan.Bilateral       = item.Bilateral;
                        loan.Amortizing      = item.Amortizing;

                        loan.AmortisationsStartPoint = loan.AmortisationsStartPoint;
                        loan.CouponDate            = loan.CouponDate;
                        loan.Notional              = loan.Notional;
                        loan.NoOfAmortisationPoint = loan.NoOfAmortisationPoint;

                        context.AddToDuplicateLoans(loan); context.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                str = ex.Message;
                if (ex.InnerException != null)
                {
                    str = str + " :: " + ex.InnerException.Message;
                }
            }
            return(str);
        }