public override async Task <EntityView> Run(EntityView arg, CommercePipelineExecutionContext context)
        {
            Condition.Requires(arg).IsNotNull(arg.Name + ": The argument cannot be null");

            ViewProperty condition = arg.Properties.FirstOrDefault(p => p.Name.EqualsOrdinalIgnoreCase("Condition"));

            if (condition == null || !condition.RawValue.ToString().StartsWith("Hc_") ||
                !condition.RawValue.ToString().EndsWith("PaymentCondition"))
            {
                return(arg);
            }

            ViewProperty paymentSelection =
                arg.Properties.FirstOrDefault(x => x.Name.EqualsOrdinalIgnoreCase("Hc_SpecificPayment"));

            if (paymentSelection != null)
            {
                IEnumerable <PaymentMethod> paymentMethods = await _getCommand.Process(context.CommerceContext);

                IEnumerable <Selection> options =
                    paymentMethods.Select(x => new Selection {
                    DisplayName = x.DisplayName, Name = x.Name
                });

                var policy = new AvailableSelectionsPolicy(options);

                paymentSelection.Policies.Add(policy);
            }

            return(arg);
        }
        public override async Task <EntityView> Run(EntityView arg, CommercePipelineExecutionContext context)
        {
            Condition.Requires(arg).IsNotNull($"{Name}: argument can not be null.");
            CommercePipelineExecutionContext executionContext;

            if (!arg.HasPolicy <SearchScopePolicy>())
            {
                executionContext = context;
                executionContext.Abort(await context.CommerceContext.AddMessage(context.GetPolicy <KnownResultCodes>().Error, "DocumentsViewError", (object[])null, "Can not perform the query. Documents view is missing information."), (object)context);
                return(null);
            }

            SearchScopePolicy scopePolicy = arg.GetPolicy <SearchScopePolicy>();

            if (string.IsNullOrEmpty(scopePolicy.Name))
            {
                executionContext = context;
                executionContext.Abort(await context.CommerceContext.AddMessage(context.GetPolicy <KnownResultCodes>().Error, "DocumentsViewError", (object[])null, "Can not perform the query. Documents view is missing information."), (object)context);
                return(null);
            }

            ViewProperty viewProperty = arg.Properties.FirstOrDefault(p => p.Name.Equals("Term", StringComparison.OrdinalIgnoreCase));

            if (viewProperty == null)
            {
                return(arg);
            }

            IndexablePolicy policyByScope = IndexablePolicy.GetPolicyByScope(context.CommerceContext, context.CommerceContext.Environment, scopePolicy.Name);

            viewProperty.Value = GetParsedTerm(viewProperty.Value, policyByScope, context.GetPolicy <AlgoliaSearchPolicy>().DefaultSearchOnlyStringFields);
            return(arg);
        }
Exemple #3
0
        public override async Task <EntityView> Run(EntityView entityView, CommercePipelineExecutionContext context)
        {
            GetCustomerDetailsViewBlockCustom detailsViewBlock = this;

            EntityViewArgument request = context.CommerceContext.GetObject <EntityViewArgument>();

            if (string.IsNullOrEmpty(request?.ViewName) || !request.ViewName.Equals(context.GetPolicy <KnownCustomerViewsPolicy>().Details, StringComparison.OrdinalIgnoreCase) && !request.ViewName.Equals(context.GetPolicy <KnownCustomerViewsPolicy>().Master, StringComparison.OrdinalIgnoreCase))
            {
                return(entityView);
            }
            if (request.ForAction.Equals(context.GetPolicy <KnownCustomerActionsPolicy>().AddCustomer, StringComparison.OrdinalIgnoreCase) && request.ViewName.Equals(context.GetPolicy <KnownCustomerViewsPolicy>().Details, StringComparison.OrdinalIgnoreCase))
            {
                await detailsViewBlock.PopulateDetails(entityView, (Customer)null, true, false, context);

                return(entityView);
            }
            bool isEditAction = request.ForAction.Equals(context.GetPolicy <KnownCustomerActionsPolicy>().EditCustomer, StringComparison.OrdinalIgnoreCase);

            if (!(request.Entity is Customer) || !isEditAction && !string.IsNullOrEmpty(request.ForAction))
            {
                return(entityView);
            }
            Customer   entity = (Customer)request.Entity;
            EntityView view;

            if (request.ViewName.Equals(context.GetPolicy <KnownCustomerViewsPolicy>().Master, StringComparison.OrdinalIgnoreCase))
            {
                ViewProperty viewProperty1 = entityView.Properties.FirstOrDefault <ViewProperty>((Func <ViewProperty, bool>)(p => p.Name.Equals("Name", StringComparison.OrdinalIgnoreCase)));
                if (viewProperty1 != null)
                {
                    viewProperty1.RawValue = entity == null || string.IsNullOrEmpty(entity.FirstName) && string.IsNullOrEmpty(entity.LastName) ? (object)string.Empty : (string.IsNullOrEmpty(entity.FirstName) || string.IsNullOrEmpty(entity.LastName) ? (!string.IsNullOrEmpty(entity.FirstName) ? (object)entity.FirstName : (object)entity.LastName) : (object)string.Format("{0} {1}", (object)entity.FirstName, (object)entity.LastName));
                    ViewProperty viewProperty2 = entityView.Properties.FirstOrDefault <ViewProperty>((Func <ViewProperty, bool>)(p => p.Name.Equals("DisplayName", StringComparison.OrdinalIgnoreCase)));
                    if (viewProperty2 != null)
                    {
                        viewProperty2.RawValue = viewProperty1.RawValue;
                    }
                    else
                    {
                        List <ViewProperty> properties    = entityView.Properties;
                        ViewProperty        viewProperty3 = new ViewProperty();
                        viewProperty3.Name     = "DisplayName";
                        viewProperty3.RawValue = viewProperty1.RawValue;
                        properties.Add(viewProperty3);
                    }
                }
                EntityView entityView1 = new EntityView();
                entityView1.EntityId = entityView.EntityId;
                entityView1.Name     = context.GetPolicy <KnownCustomerViewsPolicy>().Details;
                view = entityView1;
                entityView.ChildViews.Add((Model)view);
            }
            else
            {
                view = entityView;
            }
            await detailsViewBlock.PopulateDetails(view, entity, false, isEditAction, context);

            //return null;
            return(entityView);
        }
        private void UpdatePositionInfo()
        {
            L2SystemCore sysCore      = sys.getL2SystemCore();
            GameObject   playerObj    = sys.getPlayer().gameObject;
            Vector3      position     = playerObj.transform.position;
            ViewProperty currentView  = currentBGSys.roomSetter.getCurrentView(position.x, position.y);
            int          currentScene = sysCore.SceaneNo;

            areaString = currentScene.ToString();
            float num;
            float num2;

            if (currentView == null)
            {
                screenXString = "-1";
                screenYString = "-1";
                num           = 0f;
                num2          = 0f;
            }
            else
            {
                screenXString = currentView.ViewX.ToString();
                screenYString = currentView.ViewY.ToString();
                num           = position.x - currentView.ViewLeft;
                num2          = position.y - currentView.ViewBottom;
            }
            int num3 = (int)Mathf.Round(num * (float)BGAbstractScrollController.NumberCls);
            int num4 = (int)Mathf.Round(num2 * (float)BGAbstractScrollController.NumberCls);

            num3      /= 80;
            num4      /= 80;
            posXString = num3.ToString();
            posYString = num4.ToString();
        }
Exemple #5
0
        private static void AddSellableItemVariations(EntityView entityView, CommerceEntity entity, CommercePipelineExecutionContext context)
        {
            var policy = context.GetPolicy <KnownCatalogViewsPolicy>();

            if (entity == null || !entityView.Name.Equals(policy.Master, StringComparison.OrdinalIgnoreCase) && !entityView.Name.Equals(policy.Details, StringComparison.OrdinalIgnoreCase) && !entityView.Name.Equals(policy.ConnectSellableItem, StringComparison.OrdinalIgnoreCase))
            {
                return;
            }
            var entityView1 = new EntityView
            {
                Name          = policy.SellableItemVariants,
                EntityId      = entity.Id,
                EntityVersion = entity.EntityVersion,
                UiHint        = "Table"
            };
            var entityView2 = entityView1;
            var list        = entity.GetComponent <ItemVariationsComponent>().ChildComponents.OfType <ItemVariationComponent>().ToList();

            if (list.Count > 0)
            {
                foreach (var variationComponent in list)
                {
                    var entityView3 = new EntityView
                    {
                        Name          = policy.Variant,
                        EntityId      = entity.Id,
                        EntityVersion = entity.EntityVersion,
                        ItemId        = variationComponent.Id
                    };
                    var entityView4   = entityView3;
                    var properties1   = entityView4.Properties;
                    var viewProperty1 = new ViewProperty
                    {
                        Name       = "Id",
                        RawValue   = variationComponent.Id,
                        IsReadOnly = true,
                        UiType     = "ItemLink"
                    };
                    properties1.Add(viewProperty1);
                    var properties2   = entityView4.Properties;
                    var viewProperty2 = new ViewProperty
                    {
                        Name       = "DisplayName",
                        RawValue   = variationComponent.DisplayName,
                        IsReadOnly = true
                    };
                    properties2.Add(viewProperty2);
                    var properties3   = entityView4.Properties;
                    var viewProperty3 = new ViewProperty
                    {
                        Name       = "Disabled",
                        RawValue   = variationComponent.Disabled,
                        IsReadOnly = true
                    };
                    properties3.Add(viewProperty3);
                    entityView2.ChildViews.Add(entityView4);
                }
            }
            entityView.ChildViews.Add(entityView2);
        }
        private static void AddPropertiesToView(EntityView targetView, Type componentType, Sitecore.Commerce.Core.Component component, bool isEditViewForThisComponent)
        {
            var props = componentType.GetProperties();

            foreach (var prop in props)
            {
                System.Attribute[] propAttributes = System.Attribute.GetCustomAttributes(prop);

                if (propAttributes.SingleOrDefault(attr => attr is PropertyAttribute) is PropertyAttribute propAttr)
                {
                    if (isEditViewForThisComponent || (!isEditViewForThisComponent && propAttr.ShowInList))
                    {
                        var viewProperty = new ViewProperty
                        {
                            Name        = prop.Name,
                            DisplayName = propAttr.DisplayName,
                            RawValue    = component != null?prop.GetValue(component) : "",
                                              OriginalType = prop.PropertyType.ToString(),
                                              UiType       = propAttr?.UIType,
                                              IsReadOnly   = !isEditViewForThisComponent && propAttr.IsReadOnly,
                                              IsRequired   = propAttr.IsRequired
                        };

                        targetView.Properties.Add(viewProperty);
                    }
                }
            }
        }
        private string GetMainAccountId(CommercePipelineExecutionContext context)
        {
            var          entityView          = context.CommerceContext.GetObjects <EntityView>().FirstOrDefault(x => x.Action == addCustomerActionName);
            ViewProperty mainAccountProperty = entityView.Properties.FirstOrDefault(x => x.Name == AccountContants.MainAccountId);

            return(mainAccountProperty?.Value);
        }
        public override Task <EntityView> Run(EntityView arg, CommercePipelineExecutionContext context)
        {
            Condition.Requires(arg).IsNotNull(arg.Name + ": The argument cannot be null");

            ViewProperty condition = arg.Properties.FirstOrDefault(p => p.Name.EqualsOrdinalIgnoreCase("Condition"));

            if (condition == null || !condition.RawValue.ToString().StartsWith("Hc_") ||
                !condition.RawValue.ToString().EndsWith("Condition"))
            {
                return(Task.FromResult(arg));
            }

            foreach (ViewProperty property in arg.Properties)
            {
                if (property.Policies == null || !property.Policies.Any())
                {
                    continue;
                }

                foreach (Policy policy in property.Policies)
                {
                    if (!(policy is AvailableSelectionsPolicy selectionsPolicy))
                    {
                        continue;
                    }

                    foreach (Selection selection in selectionsPolicy.List)
                    {
                        selection.DisplayName = selection.DisplayName.PrettifyOperatorName();
                    }
                }
            }

            return(Task.FromResult(arg));
        }
Exemple #9
0
        private async Task <string> PrettifyVariableValue(ViewProperty variable, List <ViewProperty> properties,
                                                          CommerceContext commerceContext)
        {
            switch (variable.Name)
            {
            case "Hc_BasicStringCompare":
            case "Hc_Compares":
            case "Hc_Operator":
                return(variable.Value.PrettifyOperatorName());

            case "Hc_SpecificCategory":
                return(await PrettifyCategory(variable.Value, properties, commerceContext));

            case "Hc_Date":
                if (DateTimeOffset.TryParse(variable.Value, out DateTimeOffset date))
                {
                    return(date.LocalDateTime.ToString("d MMM yyyy HH:mm"));
                }

                return(variable.Value);

            case "Hc_ApplyActionTo":
                return(ApplicationOrder.Parse(variable.Value).DisplayName);

            case "TargetItemId":
                return(await PrettifyProduct(variable.Value, commerceContext));

            default:
                return(variable.Value);
            }
        }
        ///--------------------------------------------------------------------------------
        /// <summary>This method refreshes the view model.</summary>
        ///
        /// <param name="refreshChildren">Flag indicating whether children should be refreshed.</param>
        ///--------------------------------------------------------------------------------
        public void Refresh(bool refreshChildren, int refreshLevel = 0)
        {
            if (refreshChildren == true || refreshLevel > 0)
            {
            }

            #region protected
            #endregion protected

            HasErrors         = !ViewProperty.IsValid;
            HasCustomizations = ViewProperty.IsAutoUpdated == false || ViewProperty.IsEmptyMetadata(ViewProperty.ForwardInstance) == false || ChildrenHaveAnyCustomizations();
            if (HasCustomizations == false && ViewProperty.ReverseInstance != null)
            {
                // remove customizations if solely due to child customizations no longer present
                ViewProperty.IsAutoUpdated  = true;
                ViewProperty.SpecSourceName = ViewProperty.ReverseInstance.SpecSourceName;
                ViewProperty.ResetModified(ViewProperty.ReverseInstance.IsModified);
                ViewProperty.ResetLoaded(ViewProperty.ReverseInstance.IsLoaded);
                if (!ViewProperty.IsIdenticalMetadata(ViewProperty.ReverseInstance))
                {
                    HasCustomizations          = true;
                    ViewProperty.IsAutoUpdated = false;
                }
            }
            if (HasCustomizations == false)
            {
                // clear customizations
                ViewProperty.ForwardInstance = null;
                ViewProperty.ReverseInstance = null;
                ViewProperty.IsAutoUpdated   = true;
            }
            OnPropertyChanged("Items");
            OnPropertyChanged("HasCustomizations");
            OnPropertyChanged("HasErrors");
        }
Exemple #11
0
        public void AssociateToCatalogOrCategory(CommercePipelineExecutionContext context, EntityView entityView, EntityViewArgument request, string action)
        {
            var policy1    = context.GetPolicy <KnownCatalogViewsPolicy>();
            var policy2    = context.CommerceContext.Environment.GetComponent <PolicySetsComponent>().GetPolicy <SearchScopePolicy>();
            var policyList = new List <Policy>
            {
                new Policy()
                {
                    PolicyId = "EntityType", Models = new List <Model>()
                    {
                        new Model()
                        {
                            Name = "SellableItem"
                        }
                    }
                },
                policy2
            };
            var properties   = entityView.Properties;
            var viewProperty = new ViewProperty
            {
                DisplayName  = policy1.SellableItem,
                Name         = policy1.SellableItem,
                IsRequired   = true,
                Value        = string.Empty,
                UiType       = "Autocomplete",
                OriginalType = string.Empty.GetType().FullName,
                Policies     = policyList
            };

            properties.Add(viewProperty);
        }
Exemple #12
0
        // GET: Books
        public async Task <IActionResult> Index(string bookcategory, string searchstring)
        {
            IQueryable <string> categoryquery = from b in _context.Books
                                                orderby b.BType
                                                select b.BType;

            var book = from b in _context.Books select b;

            if (!String.IsNullOrEmpty(searchstring))
            {
                book = book.Where(b => b.BTitle.Contains(searchstring));
            }
            if (!String.IsNullOrEmpty(bookcategory))
            {
                book = book.Where(x => x.BType.Contains(bookcategory));
            }

            var bookcatvm = new ViewProperty
            {
                Categories = new SelectList(await categoryquery.Distinct().ToListAsync()),
                Books      = await book.ToListAsync()
            };

            return(View(bookcatvm));
        }
Exemple #13
0
        public override async Task <EntityView> Run(EntityView arg, CommercePipelineExecutionContext context)
        {
            DoActionSelectTemplatesToPullFromEnvironmentBlock thisBlock = this;

            Condition.Requires(arg).IsNotNull(thisBlock.Name + ": The entity view cannot be null.");

            if (string.IsNullOrEmpty(arg.Action) || (!arg.Action.Equals(context.GetPolicy <KnownComposerActionsPolicy>().SelectTemplatesToPullFromEnvironment, StringComparison.OrdinalIgnoreCase)))
            {
                return(await Task.FromResult(arg));
            }

            KnownResultCodes errorsCodes         = context.CommerceContext.GetPolicy <KnownResultCodes>();
            ViewProperty     environmentProperty = arg.GetProperty(ComposerConstants.EnvironmentDropdownPropertyName);
            string           propertyDisplayName = environmentProperty == null ? ComposerConstants.EnvironmentDropdownPropertyDisplayName : environmentProperty.DisplayName;

            if (string.IsNullOrEmpty(environmentProperty?.Value))
            {
                string str = await context.CommerceContext.AddMessage(errorsCodes.ValidationError, "InvalidOrMissingPropertyValue", new object[1]
                {
                    propertyDisplayName
                }, "Invalid or missing value for property '" + propertyDisplayName + "'.").ConfigureAwait(false);

                return(arg);
            }

            // get ids from view
            string[] templateIds = arg.GetProperties(p => p.UiType.Equals("Options", StringComparison.OrdinalIgnoreCase))
                                   .Where(property => {
                bool result;
                bool.TryParse(property.Value, out result);
                return(result);
            })
                                   .Select(property => property.Name)
                                   .ToArray();

            if (templateIds == null || templateIds.Length <= 0)
            {
                return(arg);
            }

            var composerTemplates = (await thisBlock._getProxyComposerTemplatesPipeline.Run(new GetProxyComposerTemplatesArgument(templateIds, environmentProperty.Value), context).ConfigureAwait(false))
                                    .ToList();

            if (composerTemplates == null || !composerTemplates.Any())
            {
                string str = await context.CommerceContext.AddMessage(errorsCodes.ValidationError, "InvalidOrMissingPropertyValue", new object[1]
                {
                    propertyDisplayName
                }, "Invalid or missing value for property '" + propertyDisplayName + "'.").ConfigureAwait(false);

                return(arg);
            }

            foreach (var template in composerTemplates)
            {
                await this._commander.CreateTemplateFromProxy(context.CommerceContext, template);
            }

            return(arg);
        }
Exemple #14
0
 public DocumentReceiptControlViewModel()
 {
     SelectedFilename              = new ViewProperty <string>("SelectedFilename", this);
     AddDeparmentCommand           = new Command(AddDeparmentHandler);
     AddSettlementCenterCommand    = new Command(AddSettlementCenterHandler);
     AddPreloadedDocumentCommand   = new Command(AddPreloadedDocumentHandler);
     DropDocumentCommand           = new Command(DropDocumentHandler);
     LoadPreloadedDocumentsCommand = new Command(LoadPreloadedDocumentsHandler);
 }
        private void PopulateAdjustmentChildView(EntityView entityView, AwardedAdjustment adjustment, CommercePipelineExecutionContext context)
        {
            EntityView entityView1 = new EntityView();

            entityView1.EntityId = entityView.EntityId;
            entityView1.ItemId   = adjustment.Name;
            entityView1.Name     = "Adjustment"; // context.GetPolicy<KnownOrderViewsPolicy>().Adjustment;
            EntityView          entityView2   = entityView1;
            List <ViewProperty> properties1   = entityView2.Properties;
            ViewProperty        viewProperty1 = new ViewProperty();

            viewProperty1.Name       = "ItemId";
            viewProperty1.IsHidden   = true;
            viewProperty1.IsReadOnly = true;
            viewProperty1.RawValue   = (object)adjustment.Name;
            properties1.Add(viewProperty1);

            entityView1.AddProperty("Name", adjustment.DisplayName);

            List <ViewProperty> properties2   = entityView2.Properties;
            ViewProperty        viewProperty2 = new ViewProperty();

            viewProperty2.Name       = "Type";
            viewProperty2.IsReadOnly = true;
            viewProperty2.RawValue   = (object)adjustment.AdjustmentType;
            properties2.Add(viewProperty2);
            List <ViewProperty> properties3   = entityView2.Properties;
            ViewProperty        viewProperty3 = new ViewProperty();

            viewProperty3.Name       = "Adjustment";
            viewProperty3.IsReadOnly = true;
            viewProperty3.RawValue   = (object)adjustment.Adjustment;
            properties3.Add(viewProperty3);
            List <ViewProperty> properties4   = entityView2.Properties;
            ViewProperty        viewProperty4 = new ViewProperty();

            viewProperty4.Name       = "Taxable";
            viewProperty4.IsReadOnly = true;
            viewProperty4.RawValue   = (object)adjustment.IsTaxable;
            properties4.Add(viewProperty4);
            List <ViewProperty> properties5   = entityView2.Properties;
            ViewProperty        viewProperty5 = new ViewProperty();

            viewProperty5.Name       = "IncludeInGrandTotal";
            viewProperty5.IsReadOnly = true;
            viewProperty5.RawValue   = (object)adjustment.IncludeInGrandTotal;
            properties5.Add(viewProperty5);
            List <ViewProperty> properties6   = entityView2.Properties;
            ViewProperty        viewProperty6 = new ViewProperty();

            viewProperty6.Name       = "AwardingBlock";
            viewProperty6.IsReadOnly = true;
            viewProperty6.RawValue   = (object)adjustment.AwardingBlock;
            properties6.Add(viewProperty6);
            entityView.ChildViews.Add((Model)entityView2);
        }
Exemple #16
0
 private void button1_Click(object sender, EventArgs e)
 {
     ViewProperty = new ViewProperty()
     {
         PropertyName        = this.textBoxPName.Text.Trim(),
         PropertyType        = this.textBoxPType.Text.Trim(),
         MappingPropertyName = this.textBoxEPName.Text.Trim(),
         MappingPropertyType = this.textBoxEPType.Text.Trim(),
         IsGeneric           = this.checkBox1.Checked,
         IsMappingGeneric    = this.checkBox1.Checked
     };
 }
        public override Task <EntityView> Run(EntityView entityView, CommercePipelineExecutionContext context)
        {
            Condition.Requires(entityView).IsNotNull($"{Name}: The argument cannot be null.");

            if (string.IsNullOrEmpty(entityView?.Action) || !entityView.Action.Equals(context.GetPolicy <KnownPromotionsActionsPolicy>().SelectBenefit, StringComparison.OrdinalIgnoreCase))
            {
                return(Task.FromResult(entityView));
            }

            Promotion promotion = context.CommerceContext.GetObjects <Promotion>().FirstOrDefault(p => p.Id.Equals(entityView.EntityId, StringComparison.OrdinalIgnoreCase));

            if (promotion == null)
            {
                return(Task.FromResult(entityView));
            }

            ViewProperty viewProperty = entityView.Properties.FirstOrDefault(p => p.Name.Equals("Action", StringComparison.OrdinalIgnoreCase));

            if (viewProperty == null)
            {
                return(Task.FromResult(entityView));
            }

            if (!(viewProperty.Value.Equals(nameof(CartItemTargetBrandSubtotalAmountOffAction)) ||
                  viewProperty.Value.Equals(nameof(CartItemTargetBrandSubtotalPercentOffAction)) ||
                  viewProperty.Value.Equals(nameof(CartItemTargetCategorySubtotalAmountOffAction)) ||
                  viewProperty.Value.Equals(nameof(CartItemTargetCategorySubtotalPercentOffAction)) ||
                  viewProperty.Value.Equals(nameof(CartItemTargetTagSubtotalAmountOffAction)) ||
                  viewProperty.Value.Equals(nameof(CartItemTargetTagSubtotalPercentOffAction))))
            {
                return(Task.FromResult(entityView));
            }

            var propertiesFromBaseClass = (new List <ViewProperty>()
            {
                entityView.Properties.FirstOrDefault(p => p.Name.Equals("Subtotal", StringComparison.OrdinalIgnoreCase)),
                entityView.Properties.FirstOrDefault(p => p.Name.Equals("SubtotalOperator", StringComparison.OrdinalIgnoreCase)),
                entityView.Properties.FirstOrDefault(p => p.Name.Equals("AmountOff", StringComparison.OrdinalIgnoreCase)),
                entityView.Properties.FirstOrDefault(p => p.Name.Equals("PercentOff", StringComparison.OrdinalIgnoreCase))
            }).Where(p => p != null).ToList();

            // Of the two base classes that exist ($Off, %Off) we have 3 feilds that need to be moved

            if (!propertiesFromBaseClass.Count.Equals(3))
            {
                return(Task.FromResult(entityView));
            }

            entityView.Properties = entityView.Properties.Except(propertiesFromBaseClass).ToList();
            entityView.Properties.AddRange(propertiesFromBaseClass);

            return(Task.FromResult(entityView));
        }
Exemple #18
0
        /// <summary>
        /// The execute.
        /// </summary>
        /// <param name="arg">
        /// The pipeline argument.
        /// </param>
        /// <param name="context">
        /// The context.
        /// </param>
        /// <returns>
        /// The <see cref="PipelineArgument"/>.
        /// </returns>
        public override Task <EntityView> Run(EntityView entityView, CommercePipelineExecutionContext context)
        {
            Condition.Requires(entityView).IsNotNull($"{this.Name}: The argument can not be null");

            var knownCartViewsPolicy   = context.GetPolicy <KnownCartViewsPolicy>();
            EntityViewArgument request = context.CommerceContext.GetObject <EntityViewArgument>();

            if (string.IsNullOrEmpty(request?.ViewName) ||
                !request.ViewName.Equals(knownCartViewsPolicy.Master, StringComparison.OrdinalIgnoreCase) ||
                !(request.Entity is Cart))
            {
                return(Task.FromResult(entityView));
            }

            Cart cart = (Cart)request.Entity;

            EntityView messagesView = new EntityView();

            messagesView.EntityId = cart.Id;
            messagesView.Name     = "Messages";
            messagesView.UiHint   = "Table";

            entityView.ChildViews.Add(messagesView);

            var messagesComponent = cart.GetComponent <MessagesComponent>();

            foreach (var message in messagesComponent.Messages)
            {
                var messageView = new EntityView();
                messageView.EntityId = cart.Id;
                messageView.ItemId   = message.Id;
                messageView.Name     = "MessageDetails";

                ViewProperty codeProperty = new ViewProperty();
                codeProperty.Name       = "Code";
                codeProperty.IsHidden   = false;
                codeProperty.IsReadOnly = true;
                codeProperty.RawValue   = message.Code;
                messageView.Properties.Add(codeProperty);

                ViewProperty textProperty = new ViewProperty();
                textProperty.Name       = "Text";
                textProperty.IsHidden   = false;
                textProperty.IsReadOnly = true;
                textProperty.RawValue   = message.Text;
                messageView.Properties.Add(textProperty);

                messagesView.ChildViews.Add(messageView);
            }


            return(Task.FromResult(entityView));
        }
Exemple #19
0
        public ViewProperty SetCustomViewProperty(EntityView customerDetailsComponent, string propertyName, bool isReadOnly, Type type, bool IsRequired)
        {
            ViewProperty viewProperty  = new ViewProperty();
            PropertyInfo property      = typeof(Customer).GetProperty(propertyName);
            object       propertyValue = customerDetailsComponent?.GetPropertyValue(propertyName);

            viewProperty.Name         = propertyName;
            viewProperty.RawValue     = propertyValue ?? string.Empty;
            viewProperty.IsReadOnly   = isReadOnly;
            viewProperty.OriginalType = type.ToString();
            viewProperty.IsRequired   = IsRequired;
            return(viewProperty);
        }
Exemple #20
0
        public static EntityView AddProperty(this EntityView entityView, string name, object rawValue, string displayName = null, string uiType = null)
        {
            ViewProperty viewProperty = new ViewProperty();

            viewProperty.Name        = name;
            viewProperty.DisplayName = displayName;
            viewProperty.RawValue    = rawValue;
            viewProperty.UiType      = uiType;

            entityView.Properties.Add(viewProperty);

            return(entityView);
        }
        public static List <ViewProperty> AddProperty(this List <ViewProperty> properties, string name, object rawValue, string displayName = null, string uiType = null)
        {
            ViewProperty viewProperty = new ViewProperty();

            viewProperty.Name        = name;
            viewProperty.DisplayName = displayName;
            viewProperty.RawValue    = rawValue;
            viewProperty.UiType      = uiType;

            properties.Add(viewProperty);

            return(properties);
        }
        private void AddMinMaxConstraintToPropertyFromProxy(ViewProperty engineViewProperty, ProxyCore.MinMaxValuePolicy proxyMinMaxValuePolicy)
        {
            if (!engineViewProperty.IsNumeric() || proxyMinMaxValuePolicy == null)
            {
                return;
            }

            engineViewProperty.SetPolicy(new MinMaxValuePolicy()
            {
                MinAllow = proxyMinMaxValuePolicy.MinAllow,
                MaxAllow = proxyMinMaxValuePolicy.MaxAllow
            });
        }
Exemple #23
0
        /// <summary>
        /// To Custom View Property
        /// </summary>
        /// <param name="input">View Property</param>
        /// <returns>Custom View Proerty</returns>
        public static CustomViewProperty ToCustomViewProperty(this ViewProperty input)
        {
            AvailableSelectionsPolicy availableSelectionPolicy = input.GetPolicy <AvailableSelectionsPolicy>();

            return(new CustomViewProperty()
            {
                DisplayName = input.DisplayName,
                Name = input.Name,
                OriginalType = input.OriginalType,
                RawValue = input.RawValue,
                Value = input.Value,
                AvailableSelectionPolicy = availableSelectionPolicy.List == null || !availableSelectionPolicy.List.Any() ? null : availableSelectionPolicy.ToCustomAvailableSelectionPolicy()
            });
        }
        ///--------------------------------------------------------------------------------
        /// <summary>This method loads an item of ViewProperty into the view model.</summary>
        ///
        /// <param name="viewProperty">The ViewProperty to load.</param>
        /// <param name="loadChildren">Flag indicating whether to perform a deeper load.</param>
        ///--------------------------------------------------------------------------------
        public void LoadViewProperty(ViewProperty viewProperty, bool loadChildren = true)
        {
            // attach the ViewProperty
            ViewProperty = viewProperty;
            ItemID       = ViewProperty.ViewPropertyID;
            Items.Clear();
            if (loadChildren == true)
            {
                #region protected
                #endregion protected

                Refresh(false);
            }
        }
        /// <summary>
        /// The execute.
        /// </summary>
        /// <param name="arg">
        /// The pipeline argument.
        /// </param>
        /// <param name="context">
        /// The context.
        /// </param>
        /// <returns>
        /// The <see cref="PipelineArgument"/>.
        /// </returns>
        public override Task <EntityView> Run(EntityView arg, CommercePipelineExecutionContext context)
        {
            Condition.Requires(arg).IsNotNull($"{Name}: The argument cannot be null.");


            var sellableItemStiboAttributesViewsPolicy = context.GetPolicy <NewActionsPolicy>();

            // Only proceed if the right action was invoked
            if (string.IsNullOrEmpty(arg.Action) || !arg.Action.Equals(sellableItemStiboAttributesViewsPolicy.New, StringComparison.OrdinalIgnoreCase))
            {
                return(Task.FromResult(arg));
            }

            // Get the sellable item from the context
            var entity = context.CommerceContext.GetObject <Sitecore.Commerce.Plugin.Catalog.SellableItem>(x => x.Id.Equals(arg.EntityId));

            if (entity == null)
            {
                return(Task.FromResult(arg));
            }

            New component;

            // Get the notes component from the sellable item or its variation
            if (!string.IsNullOrWhiteSpace(arg.ItemId))
            {
                component = entity.GetVariation(arg.ItemId).GetComponent <New>();
            }
            else
            {
                component = entity.GetComponent <New>();
            }

            DateTime     tempDate;
            ViewProperty viewPropertyLaunchDate = arg.Properties.FirstOrDefault(x => x.Name.Equals(nameof(New.US_Launch_Date_MM_DD_YYYY), StringComparison.OrdinalIgnoreCase));

            if (!string.IsNullOrEmpty(viewPropertyLaunchDate?.Value) && DateTime.TryParse(viewPropertyLaunchDate.Value, out tempDate))
            {
                component.US_Launch_Date_MM_DD_YYYY = tempDate;
            }


            context.Logger.LogInformation("Current Entity Version : " + entity.Version);

            // Persist changes
            this.Commander.Pipeline <IPersistEntityPipeline>().Run(new PersistEntityArgument(entity), context);

            return(Task.FromResult(arg));
        }
Exemple #26
0
        /// <summary>
        /// Executes the pipeline block.
        /// </summary>
        /// <param name="arg">The entity view.</param>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        public override async Task <EntityView> Run(EntityView entityView, CommercePipelineExecutionContext context)
        {
            Condition.Requires(entityView).IsNotNull($"{Name}: The argument cannot be null");

            var viewsPolicy        = context.GetPolicy <Policies.KnownInventoryViewsPolicy>();
            var entityViewArgument = context.CommerceContext.GetObject <EntityViewArgument>();
            var enablementPolicy   = context.GetPolicy <Policies.InventoryFeatureEnablementPolicy>();

            if (!enablementPolicy.InventoryFromProductView ||
                string.IsNullOrEmpty(entityViewArgument?.ViewName) ||
                !entityViewArgument.ViewName.Equals(viewsPolicy.SelectInventorySet, StringComparison.OrdinalIgnoreCase))
            {
                return(await Task.FromResult(entityView).ConfigureAwait(false));
            }

            var inventorySets =
                await CommerceCommander.Pipeline <FindEntitiesInListPipeline>().Run(
                    new FindEntitiesInListArgument(
                        typeof(InventorySet),
                        $"{CommerceEntity.ListName<InventorySet>()}",
                        0,
                        int.MaxValue),
                    context).ConfigureAwait(false);

            var availableSelectionsPolicy = new AvailableSelectionsPolicy(
                inventorySets.List.Items.Select(s =>
                                                new Selection {
                DisplayName = s.DisplayName, Name = s.Name
            }).ToList()
                ?? new List <Selection>());

            var viewProperty = new ViewProperty()
            {
                Name     = "Inventory Set",
                UiType   = "SelectList",
                Policies = new List <Policy>()
                {
                    availableSelectionsPolicy
                },
                RawValue =
                    availableSelectionsPolicy.List.Where(s => s.IsDefault).FirstOrDefault()?.Name
                    ?? availableSelectionsPolicy.List?.FirstOrDefault().Name
            };

            entityView.Properties.Add(viewProperty);

            return(entityView);
        }
Exemple #27
0
        private void AssertViewPropertyEqual(ViewProperty expectedProperty, string propertyName)
        {
            Assert.True(file.Properties.ContainsKey(propertyName), string.Format("Property [{0}] is missing.", propertyName));
            ViewProperty actual = file.Properties[propertyName];

            Assert.Equal(expectedProperty.Type, actual.Type);
            if (expectedProperty.DefaultValue == null)
            {
                Assert.Null(actual.DefaultValue);
            }
            else
            {
                Assert.NotNull(actual.DefaultValue);
                Assert.Equal(expectedProperty.DefaultValue, actual.DefaultValue);
            }
        }
        public override async Task <EntityView> Run(EntityView arg, CommercePipelineExecutionContext context)
        {
            Condition.Requires(arg).IsNotNull(arg.Name + ": The argument cannot be null");

            ViewProperty entity = arg.Properties.FirstOrDefault(p =>
                                                                p.Name.EqualsOrdinalIgnoreCase("Condition") || p.Name.EqualsOrdinalIgnoreCase("Action"));

            if (entity == null || !entity.RawValue.ToString().StartsWith("Hc_") ||
                !entity.RawValue.ToString().Contains("InCategory"))
            {
                return(arg);
            }

            ViewProperty categorySelection =
                arg.Properties.FirstOrDefault(x => x.Name.EqualsOrdinalIgnoreCase("Hc_SpecificCategory"));

            if (categorySelection == null)
            {
                return(arg);
            }

            SearchScopePolicy policyByType = SearchScopePolicy.GetPolicyByType(context.CommerceContext,
                                                                               context.CommerceContext.Environment, typeof(Category));

            if (policyByType == null)
            {
                return(arg);
            }

            var policy = new Policy
            {
                PolicyId = "EntityType",
                Models   = new List <Model> {
                    new Model {
                        Name = nameof(Category)
                    }
                }
            };

            categorySelection.UiType = "Autocomplete";
            categorySelection.Policies.Add(policy);
            categorySelection.Policies.Add(policyByType);

            await AddReadOnlyFullPath(arg, context, categorySelection);

            return(arg);
        }
        private void EditProperties(EntityView entityView, SellableItem entity)
        {
            if (entity == null)
            {
                return;
            }

            List <ViewProperty> properties   = entityView.Properties;
            ViewProperty        viewProperty = new ViewProperty();

            viewProperty.Name       = Constants.LoyaltyPoints;
            viewProperty.RawValue   = entity.GetComponent <LoyaltyPointsComponent>().Points;
            viewProperty.IsReadOnly = false;
            viewProperty.IsRequired = false;
            viewProperty.IsHidden   = false;
            properties.Add(viewProperty);
        }
        public GarbageAndRepairPaymentControlViewModel()
        {
            currentContext.OnChange += (newValue) => UpdateAllProperties();

            BarcodeString           = new ViewProperty <string>("BarcodeString", this);
            OverridedCost           = new ViewProperty <decimal>("OverridedCost", this);
            OverridedCost.OnChange += (newValue) => TotalCost.Value = currentContext.Value?.GetCostWithComission(newValue) ?? 0;
            TotalCost        = new ViewProperty <decimal>("TotalCost", this);
            IsPaymentEnable  = new ViewProperty <bool>("IsPaymentEnable", this);
            IsBarcodeFocused = new ViewProperty <bool>("IsBarcodeFocused", this);

            PayCommand          = new Command(PayHandler);
            ClearCommand        = new Command(ClearHandler);
            ApplyBarcodeCommand = new Command(ApplyBarCodeHandler);

            ClearHandler(null);
        }
		private void AssertViewPropertyEqual(ViewProperty expectedProperty, string propertyName)
		{
			Assert.IsTrue(file.Properties.ContainsKey(propertyName), string.Format("Property [{0}] is missing.", propertyName));
			ViewProperty actual = file.Properties[propertyName];
			Assert.AreEqual(expectedProperty.Type, actual.Type);

			if (expectedProperty.DefaultValue == null)
				Assert.IsNull(actual.DefaultValue);
			else
			{
				Assert.IsNotNull(actual.DefaultValue);
				Assert.AreEqual(expectedProperty.DefaultValue, actual.DefaultValue);
			}
		}