Esempio n. 1
0
        public IQueryable <Gazebo> GetGazebo()
        {
            var _db = new E_Commerce_Portal.Models.GazeboContext();
            IQueryable <Gazebo> query = _db.Gazebos;

            return(query);
        }
Esempio n. 2
0
 public void UpdateShoppingCartDatabase(String cartId, ShoppingCartUpdates[] CartItemUpdates)
 {
     using (var db = new E_Commerce_Portal.Models.GazeboContext())
     {
         try
         {
             int             CartItemCount = CartItemUpdates.Count();
             List <ShopCart> myCart        = GetCartItems();
             foreach (var cartItem in myCart)
             {
                 // Iterate through all rows within shopping cart list
                 for (int i = 0; i < CartItemCount; i++)
                 {
                     if (cartItem.Gazebo.GazeboID == CartItemUpdates[i].GazeboId)
                     {
                         if (CartItemUpdates[i].PurchaseQuantity < 1 || CartItemUpdates[i].RemoveItem == true)
                         {
                             RemoveItem(cartId, cartItem.GazeboId);
                         }
                         else
                         {
                             UpdateItem(cartId, cartItem.GazeboId, CartItemUpdates[i].PurchaseQuantity);
                         }
                     }
                 }
             }
         }
         catch (Exception exp)
         {
             throw new Exception("ERROR: Unable to Update Cart Database - " + exp.Message.ToString(), exp);
         }
     }
 }
Esempio n. 3
0
        public IQueryable <Category> GetCategories()
        {
            var _db = new E_Commerce_Portal.Models.GazeboContext();
            IQueryable <Category> query = _db.Categories;

            return(query);
        }
Esempio n. 4
0
        public IQueryable <Gazebo> GetGazebos([QueryString("id")] int?categoryId)
        {
            var _db = new E_Commerce_Portal.Models.GazeboContext();
            IQueryable <Gazebo> query = _db.Gazebos;

            if (categoryId.HasValue && categoryId > 0)
            {
                query = query.Where(g => g.CategoryID == categoryId);
            }
            return(query);
        }
Esempio n. 5
0
 public void UpdateItem(string updateCartID, int updateGazeboID, int quantity)
 {
     using (var _db = new E_Commerce_Portal.Models.GazeboContext())
     {
         try
         {
             var myItem = (from c in _db.CartItems where c.CartId == updateCartID && c.Gazebo.GazeboID == updateGazeboID select c).FirstOrDefault();
             if (myItem != null)
             {
                 myItem.Quantity = quantity;
                 _db.SaveChanges();
             }
         }
         catch (Exception exp)
         {
             throw new Exception("ERROR: Unable to Update Cart Item - " + exp.Message.ToString(), exp);
         }
     }
 }
Esempio n. 6
0
 public void RemoveItem(string removeCartID, int removeGazeboID)
 {
     using (var _db = new E_Commerce_Portal.Models.GazeboContext())
     {
         try
         {
             var myItem = (from c in _db.CartItems where c.CartId == removeCartID && c.Gazebo.GazeboID == removeGazeboID select c).FirstOrDefault();
             if (myItem != null)
             {
                 // Remove Item.
                 _db.CartItems.Remove(myItem);
                 _db.SaveChanges();
             }
         }
         catch (Exception exp)
         {
             throw new Exception("ERROR: Unable to Remove Cart Item - " + exp.Message.ToString(), exp);
         }
     }
 }