public void AddImportedQuotesAndTrades(List<CounterParty> lst) { try { using (LoanPriceEntities context = new LoanPriceEntities()) { foreach (var item in lst) { context.AddToCounterParties(item); } context.SaveChanges(); } } catch (Exception ex) { } }
public string SavecounterParty(CounterParty counterParty) { using (LoanPriceEntities context = new LoanPriceEntities()) { if (counterParty.ID <= 0) { if (context.CounterParties.Where(s => s.Name == counterParty.Name).Count() == 0) { context.AddToCounterParties(counterParty); context.SaveChanges(); return "CounterParty is added successfully"; } else return "Entry of the same Name is already exists."; } else { if (context.CounterParties.Where(s => s.Name == counterParty.Name && s.ID != counterParty.ID).Count() == 0) { context.CounterParties.Attach(counterParty); context.ObjectStateManager.ChangeObjectState(counterParty, System.Data.EntityState.Modified); context.SaveChanges(); return "CounterParty is Updated successfully"; } else return "Entry of the same Name is already exists."; } } }