예제 #1
0
        public static void AddShoppingCartItem(ShoppingCartItem item, Guid customerId)
        {
            item.CustomerId = customerId;

            var shoppingCartItem = GetExistsShoppingCartItem(customerId, item.OfferId, item.AttributesXml, item.ShoppingCartType);
            if (shoppingCartItem != null)
            {
                shoppingCartItem.Amount += item.Amount;
                UpdateShoppingCartItem(shoppingCartItem);
            }
            else
            {
                InsertShoppingCartItem(item);
            }
        }
예제 #2
0
 public static void AddShoppingCartItem(ShoppingCartItem item)
 {
     var customerId = CustomerSession.CustomerId;
     AddShoppingCartItem(item, customerId);
 }
예제 #3
0
        public static void UpdateShoppingCartItem(ShoppingCartItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            SQLDataAccess.ExecuteNonQuery
                (@"UPDATE [Catalog].[ShoppingCart] SET [ShoppingCartType] = @ShoppingCartType, [CustomerId] = @CustomerId, [OfferId] = @OfferId, [AttributesXml] = @AttributesXml, [UpdatedOn] = GetDate(),
                   [Amount] = @Amount, [DesirePrice] = @DesirePrice WHERE [ShoppingCartItemId] = @ShoppingCartItemId",
                    CommandType.Text,
                    new SqlParameter { ParameterName = "@ShoppingCartType", Value = (int)item.ShoppingCartType },
                    new SqlParameter { ParameterName = "@ShoppingCartItemId", Value = item.ShoppingCartItemId },
                    new SqlParameter { ParameterName = "@CustomerId", Value = item.CustomerId },
                    new SqlParameter { ParameterName = "@OfferId", Value = item.OfferId },
                    new SqlParameter { ParameterName = "@AttributesXml", Value = item.AttributesXml ?? String.Empty },
                    new SqlParameter { ParameterName = "@Amount", Value = item.Amount },
                    new SqlParameter { ParameterName = "@DesirePrice", Value = item.DesirePrice ?? (object)DBNull.Value }
                );
        }
예제 #4
0
 /// <summary>
 /// insert new shoppingCartItem, CreatedOn and UpdatedOn must get on sql GetDate()
 /// </summary>
 /// <param name = "item"></param>
 public static void InsertShoppingCartItem(ShoppingCartItem item)
 {
     item.ShoppingCartItemId = SQLDataAccess.ExecuteScalar<int>(@"INSERT INTO Catalog.ShoppingCart (ShoppingCartType, CustomerId, OfferId, AttributesXml, Amount, CreatedOn, UpdatedOn, DesirePrice)
            VALUES (@ShoppingCartType, @CustomerId, @OfferId, @AttributesXml, @Amount, GetDate(), GetDate(), @DesirePrice); Select SCOPE_IDENTITY();",
             CommandType.Text,
             new SqlParameter { ParameterName = "@ShoppingCartType", Value = (int)item.ShoppingCartType },
             new SqlParameter { ParameterName = "@CustomerId", Value = item.CustomerId },
             new SqlParameter { ParameterName = "@OfferId", Value = item.OfferId },
             new SqlParameter { ParameterName = "@AttributesXml", Value = item.AttributesXml ?? String.Empty },
             new SqlParameter { ParameterName = "@Amount", Value = item.Amount },
             new SqlParameter { ParameterName = "@DesirePrice", Value = item.DesirePrice ?? (object)DBNull.Value }
         );
 }
예제 #5
0
        ///// <summary>
        ///// Gets a shopping cart item
        ///// </summary>
        ///// <param name = "itemId"></param>
        ///// <returns></returns>
        //public static ShoppingCartItem GetShoppingCartItem(int itemId)
        //{
        //    if (itemId < 0)
        //    {
        //        return null;
        //    }

        //    return SQLDataAccess.ExecuteReadOne
        //        ("SELECT * FROM Catalog.ShoppingCart WHERE ItemId = @ItemId", CommandType.Text, GetFromReader,
        //            new SqlParameter { ParameterName = "@ItemId", Value = itemId }
        //        );
        //}

        //private static float GetShoppingCartItemAmount(Guid customerId, ShoppingCartItem item)
        //{
        //    return SQLDataAccess.ExecuteScalar<float>
        //         (" SELECT amount FROM [Catalog].[ShoppingCart] " +
        //          " WHERE [CustomerId] = @CustomerId AND " +
        //                " [OfferId] = @OfferId AND " +
        //                " [ShoppingCartType] = @ShoppingCartType AND " +
        //                " [AttributesXml] = @AttributesXml",
        //             CommandType.Text,
        //             new SqlParameter { ParameterName = "@CustomerId", Value = customerId },
        //             new SqlParameter { ParameterName = "@OfferId", Value = item.OfferId },
        //             new SqlParameter { ParameterName = "@AttributesXml", Value = item.AttributesXml ?? String.Empty },
        //             new SqlParameter { ParameterName = "@ShoppingCartType", Value = (int)item.ShoppingCartType }
        //         );
        //}

        public static void AddShoppingCartItem(ShoppingCartItem item)
        {
            var customerId = CustomerContext.CustomerId;

            AddShoppingCartItem(item, customerId);
        }
예제 #6
0
        public static void AddShoppingCartItem(ShoppingCartItem item)
        {
            var customerId = CustomerSession.CustomerId;

            AddShoppingCartItem(item, customerId);
        }
예제 #7
0
 public static float CalculateTaxesTotal(ShoppingCartItem basketItem, CustomerContact shippingContact, CustomerContact billingContact, float discountPercent)
 {
     var orderItem = (OrderItem)basketItem;
     return CalculateTaxesTotal(orderItem, shippingContact, billingContact, discountPercent);
 }