public static bool InsertCustomer(int customerId, string companyName, string contactName, string country, string phone) { Customer newCustomer = new Customer() { CustomerID = Convert.ToString(customerId), CompanyName = companyName, ContactName = contactName, Country = country, Phone = phone }; db.Customers.Add(newCustomer); if (db.SaveChanges() == 1) { return true; } return false; }
public static string InsertCustomer(string customerID, string companyName) { using (NorthwindEntities db = new NorthwindEntities()) { Customer customer = new Customer { CustomerID = customerID, CompanyName = companyName }; db.Customers.Add(customer); if (IsThereSameCustomer(customerID)) { string result = "The customer is already in the DB"; return result; } else { db.SaveChanges(); string result = "The customer is inserted"; return result; } } }