public void Update(DetailsOfBill detailsOfBill)
        {
            var entry = db.Entry(detailsOfBill);   //provides information, ability to perform actions on the entity

            entry.State = EntityState.Modified;
            db.SaveChanges();
        }
Пример #2
0
        public void SaveDetailsOfBill(Bill bill)
        {
            DetailsOfBill detail    = new DetailsOfBill();
            var           cartItems = GetCartItems();

            // Iterate over the items in the cart,
            // adding the order details for each
            foreach (var item in cartItems)
            {
                var orderDetail = new DetailsOfBill()
                {
                    Amount      = item.Amount,
                    BillId      = bill.Id,
                    ProductId   = item.ProductId,
                    Product     = item.Product,
                    ProductName = item.ProductName,
                    Price       = item.Price,
                    Image       = item.Image,
                    Total       = item.Amount * item.Price * (100 - item.Product.Discount) / 100
                };
                db.DetailsOfBills.Add(orderDetail);
            }
            // Save the order
            db.SaveChanges();
            // Empty the shopping cart
            EmptyCart();
        }
 public void Add(DetailsOfBill detailsOfBill)
 {
     db.DetailsOfBills.Add(detailsOfBill);
     db.SaveChanges();
 }