Пример #1
0
        protected override DriverResult Editor(ProductVatConfigurationPart part, IUpdateModel updater, dynamic shapeHelper)
        {
            // this is here so that if something errors out in some other driver,
            // we are still displaying the shape correctly

            var model = new ProductPriceEditorViewModel();

            updater.TryUpdateModel(model, Prefix, null, null);

            // added the missing values to the model
            model.DefaultVatConfigurationId = _vatConfigurationService.GetDefaultCategoryId();
            model.DefaultTerritoryName      = _vatConfigurationService
                                              .GetDefaultDestination()
                                              ?.Name ?? string.Empty;
            model.VatRates  = GetVatRates();
            model.ShowShape = true;

            if (part.As <ProductPart>() != null)
            {
                model.HasDiscount = true;
                if (model.DiscountPrice != null)
                {
                    model.DiscountPrice = model.DiscountPrice > 0 ? model.DiscountPrice : -1.0m;
                }
                else
                {
                    model.DiscountPrice = -1.0m;
                }

                if (model.DiscountTaxedPrice != null)
                {
                    model.DiscountTaxedPrice = model.DiscountTaxedPrice > 0 ? model.DiscountTaxedPrice : -1.0m;
                }
                else
                {
                    model.DiscountTaxedPrice = -1.0m;
                }
            }

            if (part.As <IShippingMethod>() != null)
            {
                model.HasDiscount     = false;
                model.OriginalPriceId = "FlexibleShippingMethodPart_DefaultPrice";
            }

            return(ContentShape("Parts_ProductPriceWithVAT_Edit",
                                () => shapeHelper.EditorTemplate(
                                    TemplateName: "Parts/ProductPriceWithVATEditor",
                                    Model: model,
                                    Prefix: Prefix
                                    )));
        }
Пример #2
0
        protected override DriverResult Editor(ProductVatConfigurationPart part, dynamic shapeHelper)
        {
            var settings = part.Settings.GetModel <ProductVatConfigurationPartInputPriceSettings>();

            var model = new ProductPriceEditorViewModel();

            if (settings != null && settings.InputFinalPrice)
            {
                model = CreateVM(part);
            }
            return(ContentShape("Parts_ProductPriceWithVAT_Edit",
                                () => shapeHelper.EditorTemplate(
                                    TemplateName: "Parts/ProductPriceWithVATEditor",
                                    Model: model,
                                    Prefix: Prefix
                                    )));
        }