public static void AddCustomer(
            string id,
            string companyName,
            string contactName,
            string contactTitle,
            string address,
            string city,
            string region,
            string postalCode,
            string country,
            string phone,
            string fax)
        {
            using (NorthwindEntities northwindEntities = new NorthwindEntities())
            {
                Customer newCustomer = new Customer()
                {
                    CustomerID = id,
                    CompanyName = companyName,
                    ContactName = contactName,
                    ContactTitle = contactTitle,
                    Address = address,
                    City = city,
                    Region = region,
                    PostalCode = postalCode,
                    Country = country,
                    Phone = phone,
                    Fax = fax
                };

                northwindEntities.Customers.Add(newCustomer);
                northwindEntities.SaveChanges();
            }
        }
 public static void ModifyCustomer(
 string id,
 string company,
 string name,
 string title,
 string address,
 string city,
 string region,
 string code,
 string country,
 string phone,
 string fax)
 {
     var db = new NorthwindEntities();
     using (db)
     {
         var newCustomer = new Customer
         {
             CustomerID = id,
             CompanyName = company,
             ContactName = name,
             ContactTitle = title,
             Address = address,
             City = city,
             Region = region,
             PostalCode = code,
             Country = country,
             Phone = phone,
             Fax = fax
         };
         var forRemoval = db.Customers.Find(id);
         if (forRemoval != null)
         {
             db.Customers.Remove(forRemoval);
             db.Customers.Add(newCustomer);
             db.SaveChanges();
         }
     }
 }
        // Task 02.
        // Create a DAO class with static methods which provide functionality
        // for inserting, modifying and deleting customers. Write a testing class.
        public static string InsertCustomer(string id, string companyName, string contactName = null, string contactTitle = null,
                                    string address = null, string city = null, string region = null, string postalCode = null,
                                    string country = null, string phoneNumber = null, string faxNumber = null)
        {
            Customer newCustomer = new Customer()
            {
                CustomerID = id,
                CompanyName = companyName,
                ContactName = contactName,
                ContactTitle = contactTitle,
                Address = address,
                City = city,
                Region = region,
                PostalCode = postalCode,
                Country = country,
                Phone = phoneNumber,
                Fax = faxNumber
            };

            NorthwindEntities context = new NorthwindEntities();

            // if the new customer does not exist in the Databases
            // we add it
            if (context.Customers.Find(id) == null)
            {
                context.Customers.Add(newCustomer);
                context.SaveChanges();

                return newCustomer.CustomerID;
            }

            return "The customer already exists in the Databases";
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="CustomerUpdatedEvent" /> class
 /// </summary>
 /// <param name="customer">The <see cref="Customer" /> which the event relates to</param>
 public CustomerUpdatedEvent(Customer customer)
     : base(string.Format("Customer: '{0}' was updated.", customer.Name), "Northwind.Web", WebEventCodes.WebExtendedBase + 100)
 {
 }
 public static void InsertNewCustomer(
     string id,
     string company,
     string name = null,
     string title = null,
     string address = null,
     string city = null,
     string region = null,
     string code = null,
     string country = null,
     string phone = null,
     string fax = null)
 {
     var db = new NorthwindEntities();
     using (db)
     {
         var newcustomer = new Customer
         {
             CustomerID = id,
             CompanyName = company,
             ContactName = name,
             ContactTitle = title,
             Address = address,
             City = city,
             Region = region,
             PostalCode = code,
             Country = country,
             Phone = phone,
             Fax = fax
         };
         db.Customers.Add(newcustomer);
         db.SaveChanges();
     }
 }