//public bool IsValidName(string name) //{ // using (LoanPriceEntities context = new LoanPriceEntities()) // { // int count = context.CreditRatings.Where(s => s. == name).Count(); // if (count == 0) // return true; // else // return false; // } //} public string SaveAgency(CreditAgency agency) { using (LoanPriceEntities context = new LoanPriceEntities()) { if (agency.ID <= 0) { //if (context.CreditRatings.Where(s => s.CreditAgency == rating.CreditAgency).Count() == 0) //{ context.AddToCreditAgencies(agency); context.SaveChanges(); return("Credit Agency is added successfully"); //} //else // return "Entry of the same Currency is already exists."; } else { //if (context.Currencies.Where(s => s.Currancy == currency.Currancy && s.ID != currency.ID).Count() == 0) //{ context.CreditAgencies.Attach(agency); context.ObjectStateManager.ChangeObjectState(agency, System.Data.EntityState.Modified); context.SaveChanges(); return("Credit Agency is Updated successfully"); //} //else // return "Entry of the same Currency is already exists."; } } }