/// <summary>
 /// Create a new Borrower object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 public static Borrower CreateBorrower(global::System.Int32 id)
 {
     Borrower borrower = new Borrower();
     borrower.ID = id;
     return borrower;
 }
        protected void btnBorrowerSave_Click(object sender, EventArgs e)
        {
            Borrower model = new Borrower();
            BorrowersBL bl = new BorrowersBL();
            if (txtBorrowerType.Text.Trim() == string.Empty)
            {
                RadWindowManager1.RadAlert("Name is required", 330, 180, "realedge associates", "alertCallBackFn"); return;
            }
            else
            {
                model.Type = txtBorrowerType.Text.Trim();
                model.Name = txtBorrowerName.Text.Trim();
                model.Region = ddlBorrowerRegion.SelectedValue;
                model.Grid = txtGrid.Text.Trim();
                model.SummitCreditEntity = txtSummitCredit.Text.Trim();
                if (!string.IsNullOrEmpty(hdnBorrower.Value))
                {
                    model.ID = Convert.ToInt32(hdnBorrower.Value);
                    LogActivity("Borrower Updated", "Email has been updated", string.Empty);
                }
                else
                {
                    LogActivity("Borrower Created", "Email has been created", string.Empty);
                }

                string str = bl.SaveBorrower(model);
                BindBorrowers();
                if (str != "Entry of the same Name is already exists.")
                {
                    hdnBorrower.Value = string.Empty;
                }

                RadWindowManager1.RadAlert(str, 330, 180, "realedge associates", "alertCallBackFn");
            }
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Borrowers EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToBorrowers(Borrower borrower)
 {
     base.AddObject("Borrowers", borrower);
 }
Esempio n. 4
0
        public string SaveBorrower(Borrower borrower)
        {
            using (LoanPriceEntities context = new LoanPriceEntities())
            {
                if (borrower.ID <= 0)
                {

                    if (context.Borrowers.Where(s => s.Name == borrower.Name).Count() == 0)
                    {
                        context.AddToBorrowers(borrower);
                        context.SaveChanges();
                        return "Borrower is added successfully";
                    }
                    else
                        return "Entry of the same Name is already exists.";
                }
                else
                {
                    if (context.Borrowers.Where(s => s.Name == borrower.Name && s.ID != borrower.ID).Count() == 0)
                    {
                        context.Borrowers.Attach(borrower);
                        context.ObjectStateManager.ChangeObjectState(borrower, System.Data.EntityState.Modified);
                        context.SaveChanges();
                        return "Borrower is Updated successfully";
                    }
                    else
                        return "Entry of the same Name is already exists.";
                }
            }
        }