protected virtual void IndexItemCustomProperties(ref ResultDocument doc, CatalogProduct item)
        {
            var properties = item.Properties;

            foreach (var propValue in item.PropertyValues.Where(x => x.Value != null))
            {
                var property     = properties.FirstOrDefault(x => string.Equals(x.Name, propValue.PropertyName, StringComparison.InvariantCultureIgnoreCase) && x.ValueType == propValue.ValueType);
                var contentField = string.Concat("__content", property != null && (property.Multilanguage && !string.IsNullOrWhiteSpace(propValue.LanguageCode)) ? "_" + propValue.LanguageCode.ToLower() : string.Empty);

                switch (propValue.ValueType)
                {
                case PropertyValueType.LongText:
                case PropertyValueType.ShortText:
                    var stringValue = propValue.Value.ToString();

                    if (!string.IsNullOrWhiteSpace(stringValue))     // don't index empty values
                    {
                        doc.Add(new DocumentField(contentField, stringValue.ToLower(), new[] { IndexStore.Yes, IndexType.Analyzed, IndexDataType.StringCollection }));
                    }

                    break;
                }

                if (doc.ContainsKey(propValue.PropertyName))
                {
                    continue;
                }


                switch (propValue.ValueType)
                {
                case PropertyValueType.Boolean:
                case PropertyValueType.DateTime:
                case PropertyValueType.Number:
                    doc.Add(new DocumentField(propValue.PropertyName, propValue.Value, new[] { IndexStore.Yes, IndexType.Analyzed }));
                    break;

                case PropertyValueType.LongText:
                    doc.Add(new DocumentField(propValue.PropertyName, propValue.Value.ToString().ToLowerInvariant(), new[] { IndexStore.Yes, IndexType.Analyzed }));
                    break;

                case PropertyValueType.ShortText:     // do not tokenize small values as they will be used for lookups and filters
                    doc.Add(new DocumentField(propValue.PropertyName, propValue.Value.ToString().ToLowerInvariant(), new[] { IndexStore.Yes, IndexType.NotAnalyzed }));
                    break;
                }
            }
        }
Beispiel #2
0
        public void ExcludedPropertyMustBeExludedForAllNestedObjects()
        {
            //Arrange
            var color = new Property {
                Id = "color", Name = "color"
            };
            var size = new Property {
                Id = "size", Name = "size"
            };
            var catalog = new Catalog
            {
                Properties = new Property[] { color, size }
            };
            var category  = new Category {
            };
            var variation = new Variation()
            {
            };
            var product = new CatalogProduct {
                Variations = new[] { variation }
            };

            //Act
            category.ExcludedProperties = new[] { new ExcludedProperty {
                                                      Name = size.Name
                                                  } };

            category.TryInheritFrom(catalog);
            product.TryInheritFrom(category);
            variation.TryInheritFrom(product);

            //Assertion

            Assert.Single(category.Properties);
            Assert.Contains(color, category.Properties);

            Assert.Single(product.Properties);
            Assert.Contains(color, product.Properties);
            var excludedProp = product.ExcludedProperties.FirstOrDefault();

            Assert.NotNull(excludedProp);
            Assert.True(excludedProp.Name == size.Name);
            Assert.True(excludedProp.IsInherited);

            Assert.Single(variation.Properties);
            Assert.Contains(color, variation.Properties);
        }
        public string GenerateExtraData(CatalogProduct product, string extraData)
        {
            switch (product.Template.ItemType)
            {
            case "poster":
                return(product.Data);

            case "trophy":
                return($"{{USERNAME}} {(char)9} {DateTime.Now.ToString("dd-MM-yyyy")} {(char)9} {extraData}");

            case "dimmer":
                return("1,1,1,#000000,255");

            default:
                return("");
            }
        }
        public async Task <ActionResult <CatalogProduct> > SaveProduct([FromBody] CatalogProduct product)
        {
            var authorizationResult = await _authorizationService.AuthorizeAsync(User, product, new CatalogAuthorizationRequirement(ModuleConstants.Security.Permissions.Update));

            if (!authorizationResult.Succeeded)
            {
                return(Unauthorized());
            }

            var result = (await InnerSaveProducts(new[] { product })).FirstOrDefault();

            if (result != null)
            {
                return(Ok(result));
            }
            return(NoContent());
        }
        protected virtual void IndexItemPrices(ref ResultDocument doc, CatalogProduct item)
        {
            var evalContext = new Domain.Pricing.Model.PriceEvaluationContext
            {
                ProductIds = new[] { item.Id }
            };

            var prices = _pricingService.EvaluateProductPrices(evalContext);


            foreach (var price in prices)
            {
                //var priceList = price.Pricelist;
                doc.Add(new DocumentField(string.Format("price_{0}_{1}", price.Currency, price.PricelistId), price.EffectiveValue, new[] { IndexStore.No, IndexType.NotAnalyzed }));
                doc.Add(new DocumentField(string.Format("price_{0}_{1}_value", price.Currency, price.PricelistId), (price.EffectiveValue).ToString(CultureInfo.InvariantCulture), new[] { IndexStore.Yes, IndexType.NotAnalyzed }));
            }
        }
Beispiel #6
0
        private MethodInfo GetProductPropertySetter(CatalogProduct product, Property property)
        {
            var name = property.Name;

            if (_productProperties.TryGetValue(name, out var result))
            {
                return(result);
            }

            var productType     = product.GetType();
            var productProperty = productType.GetProperty(name);

            result = productProperty?.GetSetMethod();

            _productProperties.Add(name, result);

            return(result);
        }
Beispiel #7
0
        public void GiveItem(Client client, CatalogProduct product, string extraData)
        {
            int id = -1;

            using (DatabaseConnection dbConnection = Engine.Locator.ConnectionPool.PopConnection())
            {
                dbConnection.SetQuery("INSERT INTO items (owner_id, definition_id, data) VALUES (@ownerId, @definitionId, @data)");
                dbConnection.AddParameter("@ownerId", client.Player.Id);
                dbConnection.AddParameter("@definitionId", product.TemplateId);
                dbConnection.AddParameter("@data", extraData);
                id = dbConnection.Insert();
            }

            if (id > 0 && client.Items != null)
            {
                client.Items.Add(id, new Item(id, client.Player.Id, product.TemplateId, extraData));
            }
        }
        public ActionResult GetNewProductByCatalogAndCategory(string catalogId, string categoryId)
        {
            var result = new CatalogProduct
            {
                CategoryId = categoryId,
                CatalogId  = catalogId,
                IsActive   = true,
                SeoInfos   = new SeoInfo [] { }
            };

            //TODO:
            //CheckCurrentUserHasPermissionForObjects(CatalogPredefinedPermissions.Create, retVal.ToModuleModel(_blobUrlResolver));
            //TODO:
            //Propery.IsManageable and IsReadonly (tests)

            _itemsService.LoadDependencies(new[] { result });
            return(Ok(result));
        }
        public ProductListPage(string title, bool isPerformingProductSelection = false)
        {
            Title = title;

            #region product list
            ProductListView productListView = new ProductListView();
            productListView.SetBinding(ProductListView.ItemsSourceProperty, "Products");
            productListView.IsPullToRefreshEnabled = true;
            productListView.SetBinding(CategoryListView.RefreshCommandProperty, "LoadProductsCommand");
            productListView.SetBinding(CategoryListView.IsRefreshingProperty, "IsBusy", mode: BindingMode.OneWay);

            productListView.ItemTapped += async(sender, e) =>
                                          await App.ExecuteIfConnected(async() =>
            {
                CatalogProduct catalogProduct = ((CatalogProduct)e.Item);
                await Navigation.PushAsync(new ProductDetailPage(catalogProduct, isPerformingProductSelection));
            });

            productListView.SetBinding(CategoryListView.HeaderProperty, ".");
            productListView.HeaderTemplate = new DataTemplate(() => {
                Label loadingLabel = new Label()
                {
                    Text      = TextResources.Products_ProductList_LoadingLabel,
                    FontSize  = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                    XAlign    = TextAlignment.Center,
                    YAlign    = TextAlignment.End,
                    TextColor = Palette._007
                };
                loadingLabel.SetBinding(Label.IsEnabledProperty, "IsBusy", mode: BindingMode.OneWay);
                loadingLabel.SetBinding(Label.IsVisibleProperty, "IsBusy", mode: BindingMode.OneWay);
                return(loadingLabel);
            });
            #endregion

            #region compase view hierarchy
            Content = new UnspacedStackLayout()
            {
                Children =
                {
                    productListView
                }
            };
            #endregion
        }
        protected virtual IndexDocument CreateDocument(CatalogProduct product, string[] tags)
        {
            var document = new IndexDocument(product.Id);

            if (tags.IsNullOrEmpty())
            {
                tags = new[] { Constants.UserGroupsAnyValue };
            }

            foreach (var tag in tags)
            {
                document.Add(new IndexDocumentField(Constants.UserGroupsFieldName, tag)
                {
                    IsRetrievable = true, IsFilterable = true, IsCollection = true
                });
            }

            return(document);
        }
Beispiel #11
0
        private List <CsvProduct> MakeMultipleExportProducts(CatalogProduct product, Dictionary <string, Price> prices, Dictionary <string, InventoryInfo> inventories)
        {
            List <CsvProduct> result = new List <CsvProduct>();

            prices.TryGetValue(product.Id, out Price price);
            inventories.TryGetValue(product.Id, out InventoryInfo inventoryInfo);

            foreach (var seoInfo in product.SeoInfos.Any() ? product.SeoInfos : new List <Domain.Commerce.Model.SeoInfo>()
            {
                null
            })
            {
                var csvProduct = new CsvProduct(product, _blobUrlResolver, price, inventoryInfo, seoInfo);

                result.Add(csvProduct);
            }

            return(result);
        }
Beispiel #12
0
 /// <summary>
 /// Add icon to given product
 /// </summary>
 private void AddIcon(CatalogProduct product, string extention, byte[] icon)
 {
     if (icon != null)
     {
         using (MemoryStream ms = new MemoryStream(icon))
         {
             var blobRelativeUrl = Path.Combine("catalog", product.Code, HttpUtility.UrlDecode(Path.ChangeExtension("icon", extention)));
             using (var targetStream = _blobStorageProvider.OpenWrite(blobRelativeUrl))
             {
                 ms.CopyTo(targetStream);
             }
             product.Images = new List <Image> {
                 new Image {
                     Url = blobRelativeUrl
                 }
             };
         }
     }
 }
 public static void ExpireEntity(CatalogProduct entity)
 {
     if (entity == null)
     {
         throw new ArgumentNullException(nameof(entity));
     }
     if (_entityRegionTokenLookup.TryRemove(entity.Id, out var token))
     {
         token.Cancel();
     }
     //need to also evict from cache a main product if given product is variation
     if (entity.MainProductId != null)
     {
         if (_entityRegionTokenLookup.TryRemove(entity.MainProductId, out var token2))
         {
             token2.Cancel();
         }
     }
 }
Beispiel #14
0
        public void Add(CatalogProduct product, string optionName, int quantity)
        {
            var option = String.IsNullOrWhiteSpace(optionName)
                             ? null
                             : product.Options.First(x => x.Name == optionName);

            Add(CreateItemKey(product.Id, optionName),
                new ShoppingCartItem
            {
                ProductId   = product.Id,
                ProductName = product.Name,
                OptionName  = option == null ? null : option.Name,
                OptionSku   = option == null ? null : option.Sku,
                Description = product.Description,
                UnitPrice   = option == null ? product.Price : option.Price ?? product.Price,
                Quantity    = quantity,
                Stock       = product.Stock,
            });
        }
Beispiel #15
0
        public async Task GetByIdsAsync_GetThenSaveItem_ReturnCachedItem()
        {
            //Arrange
            var id      = Guid.NewGuid().ToString();
            var newItem = new CatalogProduct
            {
                Id         = id,
                CatalogId  = Guid.NewGuid().ToString(),
                CategoryId = Guid.NewGuid().ToString(),
                Name       = "some product",
                Code       = "some code"
            };
            var newItemEntity = AbstractTypeFactory <ItemEntity> .TryCreateInstance().FromModel(newItem, new PrimaryKeyResolvingMap());

            var service = GetItemServiceWithPlatformMemoryCache();

            _repositoryMock.Setup(x => x.Add(newItemEntity))
            .Callback(() =>
            {
                _repositoryMock.Setup(o => o.GetItemByIdsAsync(new[] { id }, null))
                .ReturnsAsync(new[] { newItemEntity });
            });

            _catalogServiceMock.Setup(x => x.GetByIdsAsync(It.IsAny <string[]>(), default)).ReturnsAsync(new Catalog[] { new Catalog()
                                                                                                                         {
                                                                                                                             Id = newItem.CatalogId
                                                                                                                         } });
            _categoryServiceMock.Setup(x => x.GetByIdsAsync(It.IsAny <string[]>(), It.IsAny <string>(), default)).ReturnsAsync(new Category[] { new Category()
                                                                                                                                                {
                                                                                                                                                    Id = newItem.CategoryId
                                                                                                                                                } });

            //Act
            var nullItem = await service.GetByIdAsync(id, null);

            await service.SaveChangesAsync(new[] { newItem });

            var Item = await service.GetByIdAsync(id, null);

            //Assert
            Assert.NotEqual(nullItem, Item);
        }
Beispiel #16
0
        public void WorkingWithItemTest()
        {
            var itemService     = GetItemService();
            var catalogService  = GetCatalogService();
            var categoryService = GetCategoryService();
            var propertyService = GetPropertyService();

            var category = categoryService.GetById("a8bfc7cd-4363-4f12-976e-3f236433b6cf");

            //Add product property to category
            //var productProperty = new Property
            //{
            //	CategoryId = category.Id,
            //	CatalogId = category.Catalog.Id,
            //	Name = "testProp",
            //	Type = PropertyType.Product,
            //	ValueType = PropertyValueType.ShortText
            //};
            //productProperty = propertyService.Create(productProperty);


            var productProperty = propertyService.GetCategoryProperties(category.Id)
                                  .Where(x => x.Type == PropertyType.Product).FirstOrDefault();
            var productPropValue = new PropertyValue
            {
                //Property = productProperty,
                PropertyId   = productProperty.Id,
                Value        = "some value",
                PropertyName = productProperty.Name
            };
            var product = new CatalogProduct
            {
                Name       = "TestProduct",
                Code       = "Code",
                CatalogId  = category.CatalogId,
                CategoryId = category.Id
            };

            product.PropertyValues = new List <PropertyValue>();
            product.PropertyValues.Add(productPropValue);
            product = itemService.Create(product);
        }
Beispiel #17
0
        protected virtual void IndexItemPrices(ResultDocument doc, Price[] prices, CatalogProduct item)
        {
            foreach (var price in prices)
            {
                doc.Add(new DocumentField(string.Format(CultureInfo.InvariantCulture, "price_{0}_{1}", price.Currency, price.PricelistId).ToLower(), price.EffectiveValue, new[] { IndexStore.No, IndexType.NotAnalyzed }));

                // now save additional pricing fields for convinient user searches, store price with currency and without one
                doc.Add(new DocumentField(string.Format(CultureInfo.InvariantCulture, "price_{0}", price.Currency), price.EffectiveValue, new[] { IndexStore.No, IndexType.NotAnalyzed }));
                doc.Add(new DocumentField("price", price.EffectiveValue, new[] { IndexStore.No, IndexType.NotAnalyzed }));
            }

            if (prices.Length == 0) // mark product without prices defined
            {
                IndexIsProperty(doc, "unpriced");
            }
            else
            {
                IndexIsProperty(doc, "priced");
            }
        }
Beispiel #18
0
        public static bool ProductHasPropertyValues(this CatalogProduct product, Dictionary <string, string[]> propertyValues)
        {
            var result = propertyValues.Where(x => x.Key != null).All(kvp =>
            {
                var result          = false;
                var productProperty = product.Properties.FirstOrDefault(x => x.Name.EqualsInvariant(kvp.Key));

                if (productProperty != null && kvp.Value != null)
                {
                    var productPropertyValues = productProperty.Values.Where(x => x.Value != null).Select(x => x.Value.ToString()).Distinct().ToArray();
                    var valuesToSearch        = kvp.Value;

                    result = valuesToSearch.Intersect(productPropertyValues, StringComparer.OrdinalIgnoreCase).Any();
                }

                return(result);
            });

            return(result);
        }
        public override async Task InitializeAsync()
        {
            await base.InitializeAsync();

            this.Category = Category.Create(this.Fixture.Create <string>());
            await this.SeedingData <Category, CategoryId>(this.Category);

            this.Product = Product.Create(this.Fixture.Create <string>());
            await this.SeedingData <Product, ProductId>(this.Product);

            this.Catalog = Catalog.Create(this.Fixture.Create <string>());

            this.CatalogCategory =
                this.Catalog.AddCategory(this.Category.Id, this.Fixture.Create <string>());

            this.CatalogProduct =
                this.CatalogCategory.CreateCatalogProduct(this.Product.Id, this.Fixture.Create <string>());

            await this.RepositoryExecute <Catalog, CatalogId>(async repository => { await repository.AddAsync(this.Catalog); });
        }
        public string GenerateSku(CatalogProduct product)
        {
            const string leterPart = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            const string digitPart = "1234567890";
            var          res       = new StringBuilder();

            lock (_lockObject)
            {
                for (var i = 0; i < 3; i++)
                {
                    res.Append(leterPart[_random.Next(leterPart.Length)]);
                }
                res.Append("-");
                for (var i = 0; i < 8; i++)
                {
                    res.Append(digitPart[_random.Next(digitPart.Length)]);
                }
            }
            return(res.ToString());
        }
Beispiel #21
0
        /// <summary>
        /// Add property value to product
        /// </summary>
        private void AddProperty(CatalogProduct product, string propertyName, object value, PropertyValueType propertyValueType)
        {
            var property = _catalogProperties.FirstOrDefault(x => x.Name == propertyName);

            if (property != null)
            {
                var propertyValue = new PropertyValue
                {
                    PropertyId   = property.Id,
                    PropertyName = property.Name,
                    Value        = value,
                    ValueType    = propertyValueType
                };
                if (product.PropertyValues == null)
                {
                    product.PropertyValues = new List <PropertyValue>();
                }
                product.PropertyValues.Add(propertyValue);
            }
        }
Beispiel #22
0
        public static bool ProductHasPropertyValues(this CatalogProduct product, Dictionary <string, string[]> propertyValues)
        {
            return(propertyValues.Where(x => x.Key != null).All(kvp =>
            {
                // return true if no specific property values were selected, treating it as all properties
                if (kvp.Value.IsNullOrEmpty())
                {
                    return true;
                }

                var productProperty = product.Properties.FirstOrDefault(x => x.Name.EqualsInvariant(kvp.Key));
                if (productProperty == null)
                {
                    return false;
                }

                var productPropertyValues = productProperty.Values.Where(x => x.Value != null).Select(x => x.Value.ToString()).Distinct().ToList();
                return kvp.Value.Intersect(productPropertyValues, StringComparer.OrdinalIgnoreCase).Any();
            }));
        }
Beispiel #23
0
        public async Task <Catalog> AddCatalogProduct(int id, int idp)
        {
            var catalog = await context.Catalog.FindAsync(id);

            var product = await context.Product.FindAsync(idp);

            if (product == null || catalog == null)
            {
                return(null);
            }

            if (context.CatalogProduct.Any(cps => cps.ProductId == idp && cps.CatalogId == id))
            {
                return(null);
            }

            CatalogProduct cp = new CatalogProduct();

            cp.ProductId = product.ProductId;
            cp.Product   = product;
            cp.CatalogId = catalog.CatalogId;
            cp.Catalog   = catalog;

            product.CatalogProducts.Add(cp);
            catalog.CatalogProducts.Add(cp);

            context.Entry(catalog).State = EntityState.Modified;
            context.Entry(product).State = EntityState.Modified;
            context.CatalogProduct.Add(cp);

            try
            {
                await context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                return(null);
            }
            return(catalog);
        }
Beispiel #24
0
        private CsvProduct ExportAndImportProduct(CatalogProduct product)
        {
            var exportInfo = new CsvExportInfo();

            using (var stream = new MemoryStream())
            {
                var streamWriter = new StreamWriter(stream, Encoding.UTF8, 1024, true)
                {
                    AutoFlush = true
                };
                using (var csvWriter = new CsvWriter(streamWriter))
                {
                    exportInfo.Configuration = CsvProductMappingConfiguration.GetDefaultConfiguration();
                    exportInfo.Configuration.PropertyCsvColumns = product.Properties.Select(x => x.Name).Distinct().ToArray();
                    csvWriter.Configuration.Delimiter           = exportInfo.Configuration.Delimiter;
                    csvWriter.Configuration.RegisterClassMap(new CsvProductMap(exportInfo.Configuration));

                    csvWriter.WriteHeader <CsvProduct>();
                    csvWriter.NextRecord();
                    var csvProduct = new CsvProduct(product, null, null, null, null);
                    csvWriter.WriteRecord(csvProduct);
                    csvWriter.Flush();
                    stream.Position = 0;
                }

                using (var reader = new CsvReader(new StreamReader(stream, Encoding.UTF8)))
                {
                    reader.Configuration.Delimiter = exportInfo.Configuration.Delimiter;
                    reader.Configuration.RegisterClassMap(new CsvProductMap(exportInfo.Configuration));
                    reader.Configuration.MissingFieldFound = (strings, i, arg3) =>
                    {
                        //do nothing
                    };
                    reader.Configuration.TrimOptions = TrimOptions.Trim;
                    reader.Read();
                    return(reader.GetRecord <CsvProduct>());
                }
            }
        }
Beispiel #25
0
        public async Task SaveChangesAsync_SetEmptyAssociationCollections_ExistingDeleted(dataModel.AssociationEntity association)
        {
            // Arrange
            var associationServiceMock = CreateProductAssociationServiceMock(new List <dataModel.AssociationEntity>()
            {
                association
            });

            var product = new CatalogProduct()
            {
                Id           = "originalItemId",
                Name         = "Owner object",
                Associations = new List <ProductAssociation>()
                {
                }
            };
            // Act
            await associationServiceMock.SaveChangesAsync(new IHasAssociations[] { product });

            // Assert
            _catalogRepositoryMock.Verify(x => x.Remove(It.Is <dataModel.AssociationEntity>(q => q.Id == "originalId")), Times.Once);
        }
Beispiel #26
0
        public SearchResult Search(SearchCriteria criteria)
        {
            var retVal = _catalogSearchService.Search(criteria);

            if (criteria.ResponseGroup.HasFlag(SearchResponseGroup.WithCatalogs))
            {
                if (!retVal.Catalogs.Contains(_taobaoCatalog))
                {
                    retVal.Catalogs.Add(_taobaoCatalog);
                }
            }
            if (criteria.CatalogId.EqualsInvariant("Taobao") || criteria.CatalogIds.IsNullOrEmpty())
            {
                var request = new ItemsSearchRequest()
                {
                    Q = criteria.Keyword, PageNo = criteria.Skip / Math.Max(1, criteria.Take), PageSize = criteria.Take
                };
                var itemsSearchResponse = _topClient.Execute <ItemsSearchResponse>(request);
                retVal.ProductsTotalCount += (int)itemsSearchResponse.TotalResults;
                foreach (var item in itemsSearchResponse.ItemSearch.Items)
                {
                    var product = new CatalogProduct
                    {
                        Id        = item.NumIid.ToString(),
                        Catalog   = _taobaoCatalog,
                        CatalogId = _taobaoCatalog.Id,
                        Code      = item.NumIid.ToString(),
                        Name      = item.Title,
                        Images    = new Image[] { new Image {
                                                      Url = item.PicUrl
                                                  } }
                    };
                    retVal.Products.Add(product);
                }
            }

            return(retVal);
        }
        public ProductDetailDescriptionView(CatalogProduct catalogProduct)
        {
            Label nameLabel = new Label()
            {
                Text      = catalogProduct.Name,
                TextColor = Device.OnPlatform(Palette._006, Palette._006, Palette._013),
                FontSize  = Device.GetNamedSize(NamedSize.Large, typeof(Label))
            };

            Label descriptionLabel = new Label()
            {
                Text      = catalogProduct.Description,
                TextColor = Palette._007,
                FontSize  = Device.GetNamedSize(NamedSize.Default, typeof(Label))
            };

            Thickness padding = new Thickness(20);

            RelativeLayout relativeLayout = new RelativeLayout();

            relativeLayout.Children.Add(
                view: nameLabel,
                xConstraint: Constraint.RelativeToParent(parent => 0),
                yConstraint: Constraint.RelativeToParent(parent => 0),
                widthConstraint: Constraint.RelativeToParent(parent => parent.Width)
                );

            relativeLayout.Children.Add(
                view: descriptionLabel,
                xConstraint: Constraint.RelativeToParent(parent => 0),
                yConstraint: Constraint.RelativeToView(nameLabel, (parent, siblingView) => siblingView.Height + padding.VerticalThickness / 2),
                widthConstraint: Constraint.RelativeToParent(parent => parent.Width)
                );

            Padding = padding;

            Content = relativeLayout;
        }
Beispiel #28
0
        public CsvProduct(CatalogProduct product, IBlobUrlResolver blobUrlResolver, Price price, InventoryInfo inventory)
            : this()
        {
            _blobUrlResolver = blobUrlResolver;

            this.InjectFrom(product);
            PropertyValues = product.PropertyValues;
            Images         = product.Images;
            Assets         = product.Assets;
            Links          = product.Links;
            Variations     = product.Variations;
            SeoInfos       = product.SeoInfos;
            Reviews        = product.Reviews;
            Associations   = product.Associations;
            if (price != null)
            {
                Price = price;
            }
            if (inventory != null)
            {
                Inventory = inventory;
            }
        }
        public ProductDetailPage(CatalogProduct catalogProduct, bool isPerformingProductSelection = false)
        {
            _CatalogProduct = catalogProduct;

            Title = _CatalogProduct.Name;

            #region productImage
            Image image = new Image()
            {
                Source = _CatalogProduct.ImageUrl,
                Aspect = Aspect.AspectFit
            };
            #endregion

            #region ribbonView
            ProductDetailRibbonView detailRibbon = new ProductDetailRibbonView(_CatalogProduct, isPerformingProductSelection);
            #endregion

            #region descriptionView
            ProductDetailDescriptionView descriptionView = new ProductDetailDescriptionView(_CatalogProduct);
            #endregion

            #region compose view hierarchy
            Content = new ScrollView()
            {
                Content = new UnspacedStackLayout()
                {
                    Children =
                    {
                        image,
                        detailRibbon,
                        descriptionView
                    }
                }
            };
            #endregion
        }
Beispiel #30
0
        /// <summary>
        /// Add variation to given product + asset + icon + properties
        /// </summary>
        private PublishingResult AddVariation(CatalogProduct product, ModuleManifest manifest, byte[] icon, string zipModulePath, PublishingResult publishingResult)
        {
            //add variation + asset
            var variationCode = string.Format("{0}_{1}", manifest.Id, manifest.Version);

            variationCode = Regex.Replace(variationCode, @"[^A-Za-z0-9_]", "_");
            var variation = product.Variations.Where(x => x.Code == variationCode).FirstOrDefault();

            if (variation == null)
            {
                variation = new CatalogProduct
                {
                    Name          = string.Format("{0} ({1})", manifest.Title, manifest.Version),
                    Code          = variationCode,
                    MainProductId = product.Id,
                    CategoryId    = product.CategoryId,
                    CatalogId     = product.CatalogId,
                };

                AddProperty(variation, "Description", manifest.Description, PropertyValueType.LongText);
                AddProperty(variation, "ReleaseNote", manifest.ReleaseNotes, PropertyValueType.LongText);
                AddProperty(variation, "ReleaseVersion", manifest.Version, PropertyValueType.ShortText);
                AddProperty(variation, "Compatibility", manifest.PlatformVersion, PropertyValueType.ShortText);
                AddProperty(variation, "ReleaseDate", DateTime.UtcNow, PropertyValueType.DateTime);

                AddAsset(variation, zipModulePath);

                if (publishingResult == PublishingResult.None)
                {
                    AddIcon(variation, Path.GetExtension(manifest.IconUrl), icon);
                    publishingResult = PublishingResult.Variation;
                }

                _productService.Create(variation);
            }
            return(publishingResult);
        }