private static void list_supplier_parts()
        {
            using (DbBusinessContext db = new DbBusinessContext())
            {
                var suppliersAndParts = (from Suppliers in db.Suppliers
                                         join SupplierProducts in db.SupplierProducts
                                         on Suppliers.SupplierID equals SupplierProducts.SupplierID
                                         join Products in db.Products
                                         on SupplierProducts.ProductID equals Products.ID
                                         orderby Suppliers.SupplierName
                                         select new
                {
                    Suppliers.SupplierName,
                    Products.Description,
                });

                Console.WriteLine("Query 6 List all the suppliers and their Parts ordered by supplier name");
                foreach (var item in suppliersAndParts)
                {
                    //calls a method that replaces the "{", "," and "}" with spaces for formatting so that the output looks more natural
                    string result = ModifiedList(item);
                    Console.WriteLine(result);
                }
                Console.WriteLine();
            }
        }
Exemple #2
0
        public static void list_Category_products(string Category)
        {
            using (DbBusinessContext db = new DbBusinessContext())
            {
                List <Product> Query = db.Products.ToList();

                Console.WriteLine("Query Product catergory List");

                switch (Category)
                {
                case "Hardware":
                    foreach (var item in Query.Where(n => n.CategoryID == 1))
                    {
                        Console.WriteLine("{0} {1}", item.ProductID, item.Description);
                    }
                    break;

                case "Electrical Appliances":
                    foreach (var item in Query.Where(n => n.CategoryID == 2))
                    {
                        Console.WriteLine("{0} {1}", item.ProductID, item.Description);
                    }
                    break;
                }

                Console.WriteLine("");
                Console.ReadKey();
            }
        }
        static void List_Products()
        {
            using (DbBusinessContext db = new DbBusinessContext())
            {
                List <Product> ListProducts = db.Products.ToList();

                Console.WriteLine("Query 2: Product List :");
                foreach (var product in ListProducts)
                {
                    Console.WriteLine("{0}  {1}", product.ProductID, product.description);
                }
            }
            List_products(100);
        }
Exemple #4
0
        public static void list_Categories()
        {
            using (DbBusinessContext db = new DbBusinessContext())
            {
                List <Category> Query = db.Catergories.ToList();

                Console.WriteLine("Query Category List");
                foreach (var item in Query)
                {
                    Console.WriteLine("{0} {1}", item.CategoryID, item.Description);
                }
                Console.ReadLine();
            }
        }
        private static void list_categories()
        {
            using (DbBusinessContext db = new DbBusinessContext())
            {
                List <Category> Query = db.Categories.ToList();

                Console.WriteLine("Query 1 Category List");
                foreach (var item in Query)
                {
                    Console.WriteLine("{0}", item.Description);
                }
                Console.WriteLine("----------");
                Console.ReadKey();
            }
        }
        private static void list_products()
        {
            using (DbBusinessContext db = new DbBusinessContext())
            {
                List <Product> Query = db.Products.ToList();

                Console.WriteLine("Query 2 Product List");
                foreach (var item in Query)
                {
                    Console.WriteLine("{0} {1}", item.ID, item.Description);
                }
                Console.WriteLine("----------");
                Console.ReadKey();
            }
        }
Exemple #7
0
        public static void list_Products(int UpperLimit)
        {
            using (DbBusinessContext db = new DbBusinessContext())
            {
                List <Product> Query = db.Products.ToList();

                Console.WriteLine("Query Product Quantity List");
                foreach (var item in Query.Where(n => n.QuantityInStock <= UpperLimit))
                {
                    Console.WriteLine("{0} {1} {2}", item.ProductID, item.Description, item.QuantityInStock);
                }
                Console.WriteLine("");
                Console.ReadKey();
            }
        }
Exemple #8
0
        public static void list_Products()
        {
            using (DbBusinessContext db = new DbBusinessContext())
            {
                List <Product> Query = db.Products.ToList();

                Console.WriteLine("Query Product List");
                foreach (var item in Query)
                {
                    Console.WriteLine("{0} {1}", item.ProductID, item.Description);
                }
                Console.WriteLine("");
                Console.ReadLine();
            }
        }
        static void List_Categories()
        {
            using (DbBusinessContext db = new DbBusinessContext())
            {
                List <Category> ListAll = db.Categories.ToList();

                Console.WriteLine("Query 1: Category List :");
                foreach (var category in ListAll)
                {
                    Console.WriteLine("{0}  {1}", category.CategoryID, category.Description);
                }
                Console.WriteLine("///////////////////////////////////////////////////");
            }
            List_Products();
        }
Exemple #10
0
        public static void list_Suppliers()
        {
            using (DbBusinessContext db = new DbBusinessContext())
            {
                List <Supplier> Query = db.Suppliers.ToList();

                Console.WriteLine("Query Supplier List");
                foreach (var item in Query)
                {
                    Console.WriteLine("{0} {1}", item.SupplierID, item.SupplierName);
                }
                Console.WriteLine("");
                Console.ReadKey();
            }
        }
 static void List_products(int UpperLimit)
 {
     using (DbBusinessContext db = new DbBusinessContext())
     {
         List <Product> ListProductLimit = db.Products.ToList();
         Console.WriteLine("Query 3: Products over the determined quantity ");
         foreach (var product in ListProductLimit)
         {
             if (product.quantityinStock > UpperLimit)
             {
                 Console.WriteLine("{0}  {1}", product.ProductID, product.description);
             }
         }
     }
     list_product_value();
 }
        static void list_product_value()
        {
            using (DbBusinessContext db = new DbBusinessContext())
            {
                double         totalPrice       = 0;
                List <Product> ListProductPrice = db.Products.ToList();
                Console.WriteLine("Query 4: Value of all products added up");

                foreach (var product in ListProductPrice)
                {
                    totalPrice = totalPrice + product.unitPrice * product.quantityinStock;
                    Console.WriteLine("Product ID: {0}  Product Name: {1}  Product price: {2}, Quantity: {3}", product.ProductID, product.description, product.unitPrice, product.quantityinStock);
                }
                Console.WriteLine("Total Price of all products : {0}", totalPrice);
            }
            list_category_products("Hardware");
        }
Exemple #13
0
        public static void list_Product_value()
        {
            using (DbBusinessContext db = new DbBusinessContext())
            {
                List <Product> Query = db.Products.ToList();
                float          total;

                Console.WriteLine("Query Product Value List");
                foreach (var item in Query)
                {
                    total = item.UnitPrice * item.QuantityInStock;
                    Console.WriteLine("{0} {1} {2} {3} {4}", item.ProductID, item.Description, item.UnitPrice, item.QuantityInStock, total);
                }
                Console.WriteLine("");
                Console.ReadKey();
            }
        }
        private static void list_category_products(string category)
        {
            using (DbBusinessContext db = new DbBusinessContext())
            {
                var query1 = from Product in db.Products
                             join Category in db.Categories
                             on Product.CategoryID equals Category.CategoryID
                             where Category.Description.ToLower() == category.ToLower()
                             select Product;

                var list = query1.ToList();

                Console.WriteLine("Query 5 Products where the Category is 'Hardware'");
                foreach (var item in list)
                {
                    Console.WriteLine("{0} {1}", item.ID, item.Description);
                }
                Console.WriteLine("----------");
                Console.ReadKey();
            }
        }
        private static void list_products_specified_quantity(int UpperLimit)
        {
            using (DbBusinessContext db = new DbBusinessContext())
            {
                List <Product> Query = db.Products.ToList();

                Console.WriteLine("Query 3 Product List With a Quantity less than {0}", UpperLimit);
                foreach (var item in Query)
                {
                    if (item.QuantityInStock < UpperLimit)
                    {
                        Console.WriteLine("{0} {1}", item.ID, item.Description);
                    }
                    else
                    {
                    }
                }
                Console.WriteLine("----------");
                Console.ReadKey();
            }
        }
        private static void list_product_value()
        {
            using (DbBusinessContext db = new DbBusinessContext())
            {
                //changes the currency cymbol from £ to "EUR";
                CultureInfo info = new CultureInfo(System.Threading.Thread.CurrentThread.CurrentCulture.LCID);
                info.NumberFormat.CurrencySymbol = "EUR ";
                System.Threading.Thread.CurrentThread.CurrentCulture = info;

                List <Product> Query = db.Products.ToList();

                Console.WriteLine("Query 4 Product List together with their total value");
                foreach (var item in Query)
                {
                    float totalValue = item.QuantityInStock * item.UnitPrice;
                    var   sb         = new System.Text.StringBuilder();
                    sb.Append(String.Format("{0}\t\t{1}\t\t{2:C}", item.ID, item.Description, totalValue));
                    Console.WriteLine(sb);
                }
                Console.WriteLine("----------");
                Console.ReadKey();
            }
        }
 private static void AddProduct()
 {
     using (DbBusinessContext db = new DbBusinessContext())
     {
         db.SupplierProducts.Add(new SupplierProduct
         {
             DateFirstSupplied = DateTime.Now,
             FK_Product        = new Product
             {
                 category        = db.Categories.Find(1),
                 DateFirstissued = DateTime.Now,
                 Description     = "Wooden Planks",
                 QuantityInStock = 55,
                 UnitPrice       = 20.40f
             },
             FK_Supplier = new Supplier {
                 SupplierName = "Alison Hargreeves", SupplierAddressLine1 = "The Nook", SupplierAddressLine2 = "Crow's Lane"
             }
         });
         db.SaveChanges();
         Console.WriteLine("IT WORKED");
     }
 }
Exemple #18
0
        public static void addSupplier()
        {
            using (DbBusinessContext db = new DbBusinessContext())
            {
                List <Supplier> Query = db.Suppliers.ToList();

                Console.WriteLine("Query add Supplier");

                Console.WriteLine("Enter Supplier ID");
                int id = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("");

                Console.WriteLine("Enter Supplier Name");
                string name = Console.ReadLine();
                Console.WriteLine("");


                Console.WriteLine("Enter Supplier Address1");
                string Address1 = Console.ReadLine();
                Console.WriteLine("");


                Console.WriteLine("Enter Supplier Address2");
                string Address2 = Console.ReadLine();
                Console.WriteLine("");

                Supplier s = new Supplier {
                    SupplierID = id, SupplierName = name, SupplierAddressLine1 = Address1, SupplierAddressLine2 = Address2
                };

                db.Suppliers.Add(s);
                db.SaveChanges();
                Console.WriteLine("");
                Console.ReadKey();
            }
        }
 static void list_category_products(string Category)
 {
     using (DbBusinessContext db = new DbBusinessContext())
     {
     }
 }