Ejemplo n.º 1
0
        public decimal SellProduct(int productNo, int quantity)
        {
            using (ShopEntities shop = new ShopEntities())
            {
                Product product = shop.Products.Find(productNo);
                product.Stock -= quantity;
                shop.SaveChanges();

                return(quantity * product.Price);
            }
        }
Ejemplo n.º 2
0
        public decimal SellProduct(int productNo, int quantity)
        {
            using (ShopEntities db = new ShopEntities())
            {
                Product entry = db.Products.Find(productNo);
                entry.Stock -= quantity;

                db.SaveChanges();

                return(quantity * entry.Price);
            }
        }
Ejemplo n.º 3
0
        public int PlaceOrder(string customerId, int productNo, int quantity)
        {
            using (ShopEntities db = new ShopEntities())
            {
                Counter     ctr   = db.Counters.Find("order");
                OrderDetail entry = new OrderDetail
                {
                    OrderNo    = ++ctr.CurrentValue + 1000,
                    OrderDate  = DateTime.Today,
                    CustomerId = customerId,
                    ProductNo  = productNo,
                    Quantity   = quantity
                };

                db.OrderDetails.Add(entry);
                db.SaveChanges();

                return(entry.OrderNo);
            }
        }