static void Main(string[] args)
        {
            Customer newCustmer = new Customer();
            newCustmer.CustomerID = "KULO";
            newCustmer.CompanyName = "Mala";
            newCustmer.ContactName = "Misoto Kulano";
            newCustmer.ContactTitle = "Owner";
            newCustmer.Address = "Amela str 23";
            newCustmer.City = "Pelon";
            newCustmer.PostalCode = "1231";
            newCustmer.Country = "France";
            newCustmer.Phone = "3443-4323-432";
            newCustmer.Fax = "3245-243";

            using (var otherDataBase = new NorthwindEntities())
            {

                using (var dataBase = new NorthwindEntities())
                {
                    otherDataBase.Customers.Add(newCustmer);
                    otherDataBase.SaveChanges();
                    dataBase.Customers.Attach(newCustmer);
                    dataBase.Customers.Remove(newCustmer);
                    dataBase.SaveChanges();
                }
            }
        }
Example #2
0
        public static int UpdateCustomer(string customerID, Customer newCustomer)
        {
            var customerToUpdate = customers.Find(customerID);
            customerToUpdate.Address = newCustomer.Address;
            customerToUpdate.City = newCustomer.City;
            customerToUpdate.CompanyName = newCustomer.CompanyName;
            customerToUpdate.ContactName = newCustomer.ContactName;
            customerToUpdate.ContactTitle = newCustomer.ContactTitle;
            customerToUpdate.Country = newCustomer.Country;
            customerToUpdate.Fax = newCustomer.Fax;
            customerToUpdate.Phone = newCustomer.Phone;
            customerToUpdate.PostalCode = newCustomer.PostalCode;
            customerToUpdate.Region = newCustomer.Region;
            int returnCode = context.SaveChanges();

            return returnCode;
        }
Example #3
0
 public static int InsertCustomer(Customer customer)
 {
     customers.Add(customer);
     int returnCode = context.SaveChanges();
     return returnCode;
 }