Example #1
0
        public void AddToCart(Product product)
        {
            // Get the matching cart and product instances
            var cartItem = db.Carts.SingleOrDefault(
                c => c.CustomerId == ShoppingCartId &&
                c.ProductId == product.Id);

            if (cartItem == null)
            {
                // Create a new cart item if no cart item exists
                cartItem = new Cart
                {
                    Product     = product,
                    ProductId   = product.Id,
                    CustomerId  = ShoppingCartId,
                    ProductName = product.Name,
                    Price       = product.Price,
                    Total       = product.Price * product.Amount * (100 - product.Discount) / 100,
                    Image       = product.Image1,
                    Amount      = 1,
                };
                db.Carts.Add(cartItem);
            }
            else
            {
                // If the item does exist in the cart,
                // then add one to the quantity
                cartItem.Amount++;
                cartItem.Total = product.Price * cartItem.Amount * (100 - product.Discount) / 100;
            }
            // Save changes
            db.SaveChanges();
        }
 public void Add(DetailsOfBill detailsOfBill)
 {
     db.DetailsOfBills.Add(detailsOfBill);
     db.SaveChanges();
 }
 public void Add(Category category)
 {
     db.Categories.Add(category);
     db.SaveChanges();
 }
Example #4
0
 public void Add(Bill bill)
 {
     db.Bills.Add(bill);
     db.SaveChanges();
 }
 public void Add(Employee employee)
 {
     db.Employees.Add(employee);
     db.SaveChanges();
 }
Example #6
0
 public void Add(Rating rating)
 {
     db.Ratings.Add(rating);
     db.SaveChanges();
 }
 public void Add(DetailsOfInvoice detailsOfInvoice)
 {
     db.DetailsOfInvoices.Add(detailsOfInvoice);
     db.SaveChanges();
 }
Example #8
0
 public void Add(Branch branch)
 {
     db.Branchs.Add(branch);
     db.SaveChanges();
 }
Example #9
0
 public void Add(WorkAt workat)
 {
     db.WorkAts.Add(workat);
     db.SaveChanges();
 }
Example #10
0
 public void Add(Invoice invoice)
 {
     db.Invoices.Add(invoice);
     db.SaveChanges();
 }
Example #11
0
 public void Add(User_Authorize user_authorize)
 {
     db.User_Authorizes.Add(user_authorize);
     db.SaveChanges();
 }
Example #12
0
 public void Add(User user)
 {
     db.Users.Add(user);
     db.SaveChanges();
 }
Example #13
0
 public void Add(Customer customer)
 {
     db.Customers.Add(customer);
     db.SaveChanges();
 }
Example #14
0
 public void Add(Classify classify)
 {
     db.Classifys.Add(classify);
     db.SaveChanges();
 }
Example #15
0
 public void Add(Authorize authorize)
 {
     db.Authorizes.Add(authorize);
     db.SaveChanges();
 }
Example #16
0
 public void Add(Product product)
 {
     db.Products.Add(product);
     db.SaveChanges();
 }
Example #17
0
 public void Add(Area area)
 {
     db.Areas.Add(area);
     db.SaveChanges();
 }
Example #18
0
 public void Add(Provider provider)
 {
     db.Providers.Add(provider);
     db.SaveChanges();
 }