Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Customer customer = new Customer
            {
                CustomerID = "MINIV",
                Address = "Student city",
                City = "Sofia",
                CompanyName = "Telerik",
                ContactName = "Minka Ivanova",
                ContactTitle = "Owner",
                Country = "Bulgaria",
                Phone = "0711-020364",
                PostalCode = "51104"
            };

            DAO.UpdateCustomer(new Customer { CustomerID = "WOLZA" }, customer);
            
            //3. Write a method that finds all customers who have orders made in 1997 and shipped to Canada
            FindCustomers("Canada", 1997);
            Console.WriteLine();
            
            //4. Implement previous by using native SQL query and executing it through the DbContext
            FindCustomersSqlQuery("Canada", 1997);

            //5. Write a method that finds all the sales by specified region and period (start / end dates).
            Console.WriteLine(Environment.NewLine + "Orders:");
            FindSalesByRegionAndPeriod("SP", new DateTime(1997, 6, 25), new DateTime(1998, 6, 25));
        }
Exemplo n.º 2
0
 public static void InsertCustomer(Customer customer)
 {
     NorthwndEntities database = new NorthwndEntities();
     using (database)
     {
         database.Customers.Add(customer);
         database.SaveChanges();
     }
 }
Exemplo n.º 3
0
 public static void DeleteCustomer(Customer customer)
 {
     NorthwndEntities database = new NorthwndEntities();
     using (database)
     {
         var cust = database.Customers.Find(customer.CustomerID);
         database.Customers.Remove(cust);
         database.SaveChanges();
     }
 }
Exemplo n.º 4
0
 public static void UpdateCustomer(Customer oldCustomer, Customer newCustomer)
 {
     NorthwndEntities database = new NorthwndEntities();
     using (database)
     {
         var customer = database.Customers.Find(oldCustomer.CustomerID);
         customer.Address = newCustomer.Address;
         customer.City = newCustomer.City;
         customer.CompanyName = newCustomer.CompanyName;
         customer.ContactName = newCustomer.ContactName;
         customer.ContactTitle = newCustomer.ContactTitle;
         customer.Country = newCustomer.Country;
         customer.CustomerDemographics = newCustomer.CustomerDemographics;
         customer.Fax = newCustomer.Fax;
         customer.Orders = newCustomer.Orders;
         customer.Phone = newCustomer.Phone;
         customer.PostalCode = newCustomer.PostalCode;
         customer.Region = newCustomer.Region;
         database.SaveChanges();
     }
 }