Esempio n. 1
0
        public void AddToCart(int id)
        {
            // Retrieve the product from the database.
              ShoppingCartId = GetCartId();
              var cartItem = _db.CartItems.SingleOrDefault(
              c => c.CartId == ShoppingCartId
              && c.VareId == id);
              if (cartItem == null)
              {
            // Create a new cart item if no cart item exists.
               var productItem = new ProductDAL();
               MODEL.Vare enVare = this.getMODEL(productItem.getVareWithID(id));
            // MODEL.Vare product = thisitem;
            cartItem = new CartItem
            {
              ItemId = Guid.NewGuid().ToString(),
              VareId = id,
              CartId = ShoppingCartId,
              Quantity = 1,
              Vare = enVare,
              UnitSum = _db.Vareer.SingleOrDefault(
               p => p.VareId == id).Pris,
            };

            _db.CartItems.Add(cartItem);

              }
              else
              {
            // If the item does exist in the cart,
            // then add one to the quantity.
            cartItem.Quantity++;
            cartItem.UnitSum = (_db.Vareer.SingleOrDefault(
            p => p.VareId == id).Pris * (decimal)cartItem.Quantity);
              }
              _db.SaveChanges();
        }
Esempio n. 2
0
 //public List<OnlineWebShop.MODEL.Vare> getAll()
 //{
 //  var ProductDAL = new ProductDAL();
 //  List<OnlineWebShop.MODEL.Vare> allProduct = ProductDAL.getAll();
 //  return allProduct;
 //}
 public bool insertNewProduct(OnlineWebShop.DAL.Vare vare)
 {
     var ProductDAL = new ProductDAL();
       return ProductDAL.insertNewProduct(vare);
 }
Esempio n. 3
0
 public OnlineWebShop.DAL.Vare editProduct(int? id)
 {
     var ProductDAL = new ProductDAL();
       return ProductDAL.editProduct(id);
 }
Esempio n. 4
0
 public bool deleteProduct(int slettId)
 {
     var ProductDAL = new ProductDAL();
       return ProductDAL.deleteProduct(slettId);
 }
Esempio n. 5
0
 public List<OnlineWebShop.MODEL.Vare> getAll()
 {
     var ProductDAL = new ProductDAL();
       List<OnlineWebShop.MODEL.Vare> allProduct = ProductDAL.getAll();
       return allProduct;
 }