Пример #1
0
        static async Task UpdateBooleanAttribute(CustomerAccount customerAccount, IApiContext apiContext,
                                                 string attributeName, bool attributeValue)
        {
            var attributeResource = new AttributeResource(apiContext);
            var attribute         = await attributeResource.GetAttributeAsync(attributeName);

            var customerAttributeResource = new CustomerAttributeResource(apiContext);
            var customerAttribute         =
                await customerAttributeResource.GetAccountAttributeAsync(customerAccount.Id, attribute.AttributeFQN) ??
                new CustomerAttribute
            {
                AttributeDefinitionId = attribute.Id, FullyQualifiedName = attribute.AttributeFQN
            };

            attribute.AttributeFQN   = attribute.AttributeFQN.ToLower();
            customerAttribute.Values = new List <object> {
                attributeValue
            };

            if (customerAccount.Attributes.All(s => s.AttributeDefinitionId != attribute.Id))
            {
                await customerAttributeResource.AddAccountAttributeAsync(customerAttribute, customerAccount.Id, attribute.AttributeFQN);
            }
            else
            {
                await customerAttributeResource.UpdateAccountAttributeAsync(customerAttribute, customerAccount.Id, attribute.AttributeFQN);
            }
        }
Пример #2
0
        public async Task <Mozu.Api.Contracts.ProductAdmin.Attribute> UpdateAttribute(int tenantId, int?siteId,
                                                                                      int?masterCatalogId, Mozu.Api.Contracts.ProductAdmin.Attribute attribute)
        {
            _apiContext = new ApiContext(tenantId, siteId, masterCatalogId);

            var attributeResource = new AttributeResource(_apiContext);
            var updatedAttribute  = await attributeResource.UpdateAttributeAsync(attribute, attribute.AttributeFQN, null);

            return(updatedAttribute);
        }
Пример #3
0
        public async Task <IEnumerable <Mozu.Api.Contracts.ProductAdmin.Attribute> > GetAttributes(int tenantId, int?siteId,
                                                                                                   int?masterCatalogId, int?startIndex, int?pageSize, string sortBy = null, string filter = null)
        {
            _apiContext = new ApiContext(tenantId, siteId, masterCatalogId);

            var attributeResource = new AttributeResource(_apiContext);
            var attributes        = await attributeResource.GetAttributesAsync(startIndex, pageSize, sortBy, filter, null);

            return(attributes.Items);
        }
Пример #4
0
        public static async Task <bool> IsRewardsAssigned(this CustomerAccount customerAccount, IApiContext apiContext)
        {
            var attributeResource = new AttributeResource(apiContext);
            var attribute         = await attributeResource.GetAttributeAsync(AttributeConstants.RewardsAssigned);

            var customerAttributeResource = new CustomerAttributeResource(apiContext);
            var attributeCustomer         =
                await customerAttributeResource.GetAccountAttributeAsync(customerAccount.Id, attribute.AttributeFQN);

            return(attributeCustomer != null && attributeCustomer.Values.Any(a => a.Equals(true)));
        }
Пример #5
0
        protected async override Task <bool> GetDataAsync()
        {
            var resource = new AttributeResource(Context);

            _results = await resource.GetAttributesAsync(startIndex : StartIndex, pageSize : PageSize, sortBy : SortBy, filter : Filter, responseFields : ResponseFields);

            TotalCount = _results.TotalCount;
            PageCount  = _results.PageCount;
            PageSize   = _results.PageSize;
            return(_results.Items != null && _results.Items.Count > 0);
        }
Пример #6
0
        static async Task <bool> CheckBooleanAttributeIsSet(CustomerAccount customerAccount, IApiContext apiContext, string attributeName)
        {
            var attributeResource = new AttributeResource(apiContext);
            var attribute         = await attributeResource.GetAttributeAsync(attributeName);

            attribute.AttributeFQN = attribute.AttributeFQN.ToLower();
            var customerAttributeResource = new CustomerAttributeResource(apiContext);
            var attributeCustomer         =
                await customerAttributeResource.GetAccountAttributeAsync(customerAccount.Id, attribute.AttributeFQN);

            return(attributeCustomer != null && attributeCustomer.Values.Any(a => a.Equals(true)));
        }