Ejemplo n.º 1
0
 public string SaveCountry(tblCountry country)
 {
     using (LoanPriceEntities context = new LoanPriceEntities())
     {
         if (country.ID <= 0)
         {
             if (context.tblCountry.Where(s => s.Name == country.Name).Count() == 0)
             {
                 context.AddTotblCountry(country);
                 context.SaveChanges();
                 return "Country is added successfully";
             }
             else
                 return "Entry of the same Name is already exists.";
         }
         else
         {
             context.tblCountry.Attach(country);
             context.ObjectStateManager.ChangeObjectState(country, System.Data.EntityState.Modified);
             context.SaveChanges();
             return "Country is Updates successfully";
         }
     }
 }