Exemple #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();
            }
        }
Exemple #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();
            }
        }
Exemple #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();
            }
        }
Exemple #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();
            }
        }
Exemple #5
0
        public static void InsertCustomer(Customer custumer)
        {
            var dbContex = new NorthwindEntities();

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