Beispiel #1
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.");
             }
         }
     }
 }
Beispiel #2
0
 public void AddImportedQuotesAndTrades(List <Borrower> lst)
 {
     try
     {
         using (LoanPriceEntities context = new LoanPriceEntities())
         {
             foreach (var item in lst)
             {
                 context.AddToBorrowers(item);
             }
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
     }
 }