Beispiel #1
0
        public static void ChangeCustomerContactName(string customerId, string newName)
        {
            var dbContex = new NorthwindEntities();

            using (dbContex)
            {
                var customer = dbContex.Customers
                               .FirstOrDefault(c => c.CustomerID == customerId);

                if (customer == null)
                {
                    return;
                }

                customer.ContactName = newName;
                dbContex.SaveChanges();
            }
        }
Beispiel #2
0
        public static void DeleteCustomer(string custumerId)
        {
            var dbContex = new NorthwindEntities();

            using (dbContex)
            {
                var customer = dbContex.Customers
                               .Where(c => c.CustomerID == custumerId)
                               .FirstOrDefault();
                if (customer == null)
                {
                    return;
                }

                dbContex.Customers.Remove(customer);
                dbContex.SaveChanges();
            }
        }
Beispiel #3
0
        public static void DeleteCustomer(string custumerId)
        {
            var dbContex = new NorthwindEntities();

            using (dbContex)
            {
                var customer = dbContex.Customers
                                .Where(c => c.CustomerID == custumerId)
                                .FirstOrDefault();
                if (customer == null)
                {
                    return;
                }

                dbContex.Customers.Remove(customer);
                dbContex.SaveChanges();
            }
        }
Beispiel #4
0
        public static void ChangeCustomerContactName(string customerId, string newName)
        {
            var dbContex = new NorthwindEntities();

            using (dbContex)
            {
                var customer = dbContex.Customers
                    .FirstOrDefault(c => c.CustomerID == customerId);

                if (customer == null)
                {
                    return;
                }

                customer.ContactName = newName;
                dbContex.SaveChanges();
            }
        }
Beispiel #5
0
        public static void InsertCustomer(Customer custumer)
        {
            var dbContex = new NorthwindEntities();

            using (dbContex)
            {
                dbContex.Customers.Add(custumer);
                dbContex.SaveChanges();
            }
        }