Esempio n. 1
0
        public static bool AddStock(Stock stock)
        {
            using (var dboContext = new MCDBContext())
            {
                dboContext.Stock.Add(stock);
                return(dboContext.SaveChanges() > 0);
            }

            return(false);
        }
Esempio n. 2
0
        public static bool AddOrderLine(OrderLine orderLine)
        {
            using (var dboContext = new MCDBContext())
            {
                dboContext.OrderLine.Add(orderLine);
                return(dboContext.SaveChanges() > 0);
            }

            return(false);
        }
Esempio n. 3
0
        public static bool AddCustomerOrder(CustomerOrder customerOrder)
        {
            using (var dboContext = new MCDBContext())
            {
                dboContext.CustomerOrder.Add(customerOrder);
                return(dboContext.SaveChanges() > 0);
            }

            return(false);
        }
Esempio n. 4
0
        public void AddProduct(Product product)
        {
            Console.WriteLine("Try to add a new entry in database SQLite");

            using (var dboContext = new MCDBContext())
            {
                dboContext.Product.Add(product);
                dboContext.SaveChanges();
            }

            Console.WriteLine("End");
        }
Esempio n. 5
0
        public static List <Stock> GetAllStock()
        {
            List <Stock> listStocks = new List <Stock>();

            using (var dboContext = new MCDBContext())
            {
                var dbList = dboContext.Stock;

                foreach (Stock Stock in dbList)
                {
                    listStocks.Add(Stock);
                }
            }

            return(listStocks);
        }
Esempio n. 6
0
        public static List <OrderLine> GetAllOrderLine()
        {
            List <OrderLine> listOrderLines = new List <OrderLine>();

            using (var dboContext = new MCDBContext())
            {
                var dbList = dboContext.OrderLine;

                foreach (OrderLine OrderLine in dbList)
                {
                    listOrderLines.Add(OrderLine);
                }
            }

            return(listOrderLines);
        }
Esempio n. 7
0
        public static List <CustomerOrder> GetAllCustomerOrder()
        {
            List <CustomerOrder> listCustomerOrders = new List <CustomerOrder>();

            using (var dboContext = new MCDBContext())
            {
                var DbList = dboContext.CustomerOrder;

                foreach (CustomerOrder CustomerOrder in DbList)
                {
                    listCustomerOrders.Add(CustomerOrder);
                }
            }

            return(listCustomerOrders);
        }
Esempio n. 8
0
        public void GetProducts()
        {
            Console.WriteLine("Get products in database");

            using (var dboContext = new MCDBContext())
            {
                var listProduct = dboContext.Product;

                foreach (Product aProduct in listProduct)
                {
                    Console.WriteLine($"{aProduct.Id} | {aProduct.Name} | {aProduct.Price}");
                }
            }

            Console.WriteLine("End");
            Console.ReadLine();
        }
Esempio n. 9
0
 public OpenSeatsController(MCDBContext context)
 {
     _dbContext = context;
 }