Esempio n. 1
0
        public static void AddInvoice(ProdContext prodContext)
        {
            Invoice inv = new Invoice {
            };

            prodContext.Invoices.Add(inv);
            prodContext.SaveChanges();
        }
Esempio n. 2
0
        public static void AddProduct(ProdContext prodContext)
        {
            Console.WriteLine("write name of product");
            string  prodName = Console.ReadLine();
            Product prod1    = new Product {
                Name = prodName
            };

            prodContext.Products.Add(prod1);
            prodContext.SaveChanges();
        }
Esempio n. 3
0
        public static void AddCategory(ProdContext prodContext)
        {
            Console.WriteLine("write name of category");
            string   catName = Console.ReadLine();
            Category cat1    = new Category {
                Name = catName
            };

            prodContext.Categories.Add(cat1);
            prodContext.SaveChanges();
        }
Esempio n. 4
0
        public static void AddCustomer(ProdContext prodContext)
        {
            Console.WriteLine("Write name of customer");
            String   suppName = Console.ReadLine();
            Customer cust     = new Customer {
                CompanyName = suppName, Discount = 0.2F
            };

            prodContext.Companies.Add(cust);
            prodContext.SaveChanges();
        }
Esempio n. 5
0
        //public static void AddSupplier(ProdContext prodContext)
        //{
        //    Console.WriteLine("Write name of supplier");
        //    String suppName = Console.ReadLine();
        //    Supplier supp1 = new Supplier { CompanyName = suppName };

        //    prodContext.Suppliers.Add(supp1);
        //    prodContext.SaveChanges();
        //}

        public static void AddSupplier(ProdContext prodContext)
        {
            Console.WriteLine("Write name of supplier");
            String   suppName = Console.ReadLine();
            Supplier supp1    = new Supplier {
                CompanyName = suppName
            };

            prodContext.Companies.Add(supp1);
            prodContext.SaveChanges();
        }
Esempio n. 6
0
        public static void ConnectProductToCategory(ProdContext prodContext)
        {
            Console.WriteLine("Write name of product");
            string prodName = Console.ReadLine();

            Console.WriteLine("Write name of category");
            String conName = Console.ReadLine();

            Product product = prodContext.Products.Where(p => p.Name == prodName).FirstOrDefault();

            Category category = prodContext.Categories.Where(c => c.Name == conName).FirstOrDefault();

            product.Category = category;
            prodContext.SaveChanges();
        }
Esempio n. 7
0
        //public static void ConnectProductToSupplier(ProdContext prodContext)
        //{
        //    Console.WriteLine("Write name of product");
        //    string prodName = Console.ReadLine();

        //    Console.WriteLine("Write name of supplier");
        //    String suppName = Console.ReadLine();

        //    Product product = prodContext.Products.Where(p => p.Name == prodName).FirstOrDefault();

        //    Supplier supplier = prodContext.Suppliers.Where(s => s.CompanyName == suppName).FirstOrDefault();

        //    product.Supplier = supplier;
        //    prodContext.SaveChanges();
        //}
        public static void ConnectProductToSupplier(ProdContext prodContext)
        {
            Console.WriteLine("Write name of product");
            string prodName = Console.ReadLine();

            Console.WriteLine("Write name of supplier");
            String suppName = Console.ReadLine();

            Product product = prodContext.Products.Where(p => p.Name == prodName).FirstOrDefault();

            Company company = prodContext.Companies.Where(s => s.CompanyName == suppName).FirstOrDefault();

            Supplier supplier = (Supplier)company;

            product.Supplier = supplier;
            prodContext.SaveChanges();
        }
Esempio n. 8
0
        public static void ConnectProductToInvoice(ProdContext prodContext)
        {
            Console.WriteLine("Write name of product");
            String prodName = Console.ReadLine();

            Console.WriteLine("Write number of invoice");
            String invNumStr = Console.ReadLine();
            int    invNum    = Int32.Parse(invNumStr);

            Product product = prodContext.Products.Where(p => p.Name == prodName).FirstOrDefault();

            Invoice invoice = prodContext.Invoices.Where(i => i.InvoiceNumber == invNum).FirstOrDefault();

            prodContext.ProductInvoices.Add(new ProductInvoice
            {
                ProductID     = product.ProductID,
                Product       = product,
                InvoiceNumber = invoice.InvoiceNumber,
                Invoice       = invoice
            });
            prodContext.SaveChanges();
        }