コード例 #1
0
ファイル: ProductsController.cs プロジェクト: mtrutledge/core
        private SystemOperationResult InventoryCheck(ProductPageViewModel model)
        {
            var data = HccApp.CatalogServices.InventoryCheck(model.LocalProduct, model.Selections);

            model.StockMessage       = data.InventoryMessage;
            model.IsAvailableForSale = data.IsAvailableForSale;

            var formQuantity = Request.Form["qty"];

            if (model.LocalProduct.IsUserSuppliedPrice)
            {
                formQuantity = "1";
            }

            if (!string.IsNullOrEmpty(formQuantity))
            {
                formQuantity = security.InputFilter(formQuantity.Trim(), PortalSecurity.FilterFlag.NoMarkup);
            }

            var qty = 0;

            if (int.TryParse(formQuantity, out qty))
            {
                var li = ConvertProductToLineItem(model);
                li.Quantity = Convert.ToInt16(formQuantity);
                return(HccApp.CheckForStockOnItems(li));
            }
            return(new SystemOperationResult(false, Localization.GetString("EnterProperQty")));
        }
コード例 #2
0
        private bool CheckForStockOnItems(CartViewModel model)
        {
            var result = HccApp.CheckForStockOnItems(model.CurrentOrder);

            if (result.Success)
            {
                return(true);
            }
            FlashFailure(result.Message);
            return(false);
        }
コード例 #3
0
        private SystemOperationResult InventoryCheck(ProductPageViewModel model)
        {
            var data = HccApp.CatalogServices.InventoryCheck(model.LocalProduct, model.Selections);

            model.StockMessage       = data.InventoryMessage;
            model.IsAvailableForSale = data.IsAvailableForSale;

            var formQuantity = Request.Form["qty"];
            var qty          = 0;

            if (int.TryParse(formQuantity, out qty))
            {
                var li = ConvertProductToLineItem(model);
                li.Quantity = Convert.ToInt16(formQuantity);
                return(HccApp.CheckForStockOnItems(li));
            }
            return(new SystemOperationResult(false, Localization.GetString("EnterProperQty")));
        }
コード例 #4
0
ファイル: OrderItems.ascx.cs プロジェクト: crazyants/core-1
        protected void btnUpdateQuantities_Click(object sender, EventArgs e)
        {
            var gridView = CurrentOrder.IsRecurring ? gvSubscriptions : gvItems;

            foreach (GridViewRow row in gridView.Rows)
            {
                if (row.RowType != DataControlRowType.DataRow)
                {
                    continue;
                }

                var itemId = (long)gridView.DataKeys[row.RowIndex].Value;
                var txtQty = row.FindControl("txtQty") as TextBox;

                var li       = CurrentOrder.GetLineItem(itemId);
                var quantity = int.Parse(txtQty.Text.Trim());

                var opResult = HccApp.OrderServices.OrdersUpdateItemQuantity(itemId, quantity, CurrentOrder);
                if (!string.IsNullOrEmpty(opResult.Message))
                {
                    ucMessageBox.ShowError(opResult.Message);
                }
            }

            var result = HccApp.CheckForStockOnItems(CurrentOrder);

            if (!result.Success)
            {
                ucMessageBox.ShowWarning(result.Message);
            }

            HccApp.CalculateOrderAndSave(CurrentOrder);

            var handler = OrderEdited;

            if (handler != null)
            {
                handler(this, EventArgs.Empty);
            }
        }