Example #1
0
        //Naming convention ok

        public bool AddProduct(Product product)
        {
            using (var dboContext = new MCDBContext())
            {
                dboContext.Product.Add(product);
                return(dboContext.SaveChanges() > 0);
            }

            return(false);
        }
Example #2
0
        //Naming convention ok

        public bool AddCustomer(Customer customer)
        {
            using (var dboContext = new MCDBContext())
            {
                dboContext.Customer.Add(customer);
                return(dboContext.SaveChanges() > 0);
            }

            return(false);
        }
Example #3
0
        public List <Product> GetAllProducts()
        {
            List <Product> listProducts = new List <Product>();

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

                foreach (Product product in dbList)
                {
                    listProducts.Add(product);
                }
            }

            return(listProducts);
        }
Example #4
0
        public List <Customer> GetAllCustomer()
        {
            List <Customer> listCustomers = new List <Customer>();

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

                foreach (Customer Customer in DbList)
                {
                    listCustomers.Add(Customer);
                }
            }

            return(listCustomers);
        }
Example #5
0
        public List <Product> GetProductsByCategory(int categoryId)
        {
            List <Product> listProducts = new List <Product>();

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

                foreach (Product product in dbList)
                {
                    if (product.CategoryId == categoryId)
                    {
                        listProducts.Add(product);
                    }
                }
            }

            return(listProducts);
        }