示例#1
0
        public static void CreateNewOrder(string customerId, DateTime orderDate, string shipCountry, List <OrderDetail> orderDetails)
        {
            using (var db = new SouthwindContext())
            {
                db.Add(new Order()
                {
                    CustomerId   = customerId,
                    OrderDate    = orderDate,
                    ShipCountry  = shipCountry,
                    OrderDetails = orderDetails
                });

                db.SaveChanges();
            }
        }
示例#2
0
        public static void CreateNewProduct(string productName, double price, int stock = 0)
        {
            using (var db = new SouthwindContext())
            {
                db.Add(new Product()
                {
                    ProductName  = productName,
                    Price        = price,
                    Stock        = stock,
                    DateAdded    = DateTime.Now,
                    Discontinued = false
                });

                db.SaveChanges();
            }
        }
示例#3
0
        public static void CreateNewCustomer(string customerId, string contactName, string city, string postalCode, string country)
        {
            using (var db = new SouthwindContext())
            {
                db.Add(new Customer()
                {
                    CustomerId  = customerId,
                    ContactName = contactName,
                    City        = city,
                    PostalCode  = postalCode,
                    Country     = country
                });

                db.SaveChanges();
            }
        }