public ItemAssetViewModel(IViewModelsFactory<IPickAssetViewModel> vmFactory, ItemAsset item)
		{
			_vmFactory = vmFactory;
			InnerItem = item;

			AssetPickCommand = new DelegateCommand(RaiseItemPickInteractionRequest);
			CommonConfirmRequest = new InteractionRequest<Confirmation>();
		}
		private Item SetupItem(Item item, string containerId, string propertySetId, ImportItem[] systemValues, IEnumerable<ImportItem> customValues, ICatalogRepository repository, string taxCategory)
		{
			var retVal = (Item)InitializeItem(item, systemValues);
			retVal.CatalogId = containerId;
			var propSet = repository.PropertySets.Expand("PropertySetProperties/Property/PropertyValues").Where(x => x.PropertySetId == propertySetId).First();
			var resProps = InitializeProperties(propSet.PropertySetProperties.ToArray(), customValues, retVal.ItemId);
			retVal.ItemPropertyValues.Add(resProps);
			retVal.PropertySetId = propSet.PropertySetId;

			if (!string.IsNullOrEmpty(taxCategory))
			{
				var cat =
					repository.TaxCategories.Where(x => x.TaxCategoryId == taxCategory || x.Name == taxCategory).FirstOrDefault();
				retVal.TaxCategory = cat != null ? cat.TaxCategoryId : null;
			}

			if (!string.IsNullOrEmpty(systemValues.First(x => x.Name == "ItemAsset").Value))
			{
				var itemAsset = new ItemAsset
				{
					AssetType = "image",
					ItemId = retVal.ItemId,
					AssetId = systemValues.First(x => x.Name == "ItemAsset").Value,
					GroupName = "primaryimage"
				};
				retVal.ItemAssets.Add(itemAsset);
			}

			if (!string.IsNullOrEmpty(systemValues.First(x => x.Name == "EditorialReview").Value))
			{
				var editorial = new CatalogEntityFactory().CreateEntity<EditorialReview>();
				editorial.ReviewState = (int) ReviewState.Active;
				editorial.Content = systemValues.First(x => x.Name == "EditorialReview").Value;
				editorial.ItemId = retVal.ItemId;
				retVal.EditorialReviews.Add(editorial);
			}

			return retVal;
		}
		private static Product CreateProduct(string catalogId, string categoryId, string name, string propertySetId)
		{
			Product product = new Product();
			//product.CatalogId = catalogId;
			product.Name = name;
			product.Code = product.ItemId;
			product.StartDate = DateTime.Now.AddYears(-1);
			product.EndDate = DateTime.Now.AddYears(1);
			product.IsActive = true;
			product.CatalogId = catalogId;
			product.MinQuantity = 1;
			product.MaxQuantity = 10;

			product.Weight = 2.3m;
			product.TrackInventory = false;
			//product.SetPropertyValue<string>("Brand", brand);

			string description = @"The Nokia 2610 is an easy to use device that combines multiple messaging options including email, instant messaging, and more. You can even download MP3 ringtones, graphics, and games straight to the phone, or surf the Internet with Cingular's MEdia Net service. It's the perfect complement to Cingular service for those even remotely interested in mobile Web capabilities in an affordable handset.";

			product.ItemPropertyValues.Add(new ItemPropertyValue() { ItemId = product.ItemId, LongTextValue = description, Name = "Description" });

			string design = "Compact and stylish, the 2610 features a candybar design sporting a bright 128 x 128 pixel display capable of displaying over 65,000 colors. Most of the phone's features and on-screen menus are controlled by a center toggle on the control pad. A standard hands-free headphone jack is provided, as are volume control keys, and there's even a \"Go-To\" button that can be assigned by the user for quick access to favorite applications. Lastly, the included speakerphone allows you to talk handsfree, and because the phone sports an internal antenna, there's nothing to snag or break off.";
			product.ItemPropertyValues.Add(new ItemPropertyValue() { ItemId = product.ItemId, LongTextValue = design, Name = "Design" });
			product.ItemPropertyValues.Add(new ItemPropertyValue() { ItemId = product.ItemId, LongTextValue = "2610", Name = "Model" });

			//var propertySet = catalog.PropertySets[0];

			//product.PropertySet = propertySet;
			product.PropertySetId = propertySetId;

			////Add associations
			//AssociationGroup group = new AssociationGroup();

			//group.Description = "Related products";
			//group.Name = "RelatedProducts";
			//group.ItemId = product.ItemId;

			//Association association = new Association();
			//association.AssociationType = AssociationTypes.Optional;
			//association.ItemId = product.ItemId;
			////association.CatalogItem = product;
			//association.AssociationGroupId = group.AssociationGroupId;
			//group.Associations.Add(association);

			//product.AssociationGroups.Add(group);

			//AssociationGroup group2 = new AssociationGroup();
			//group2.Description = "Accessory products";
			//group2.Name = "ProductAccessories";
			//group2.ItemId = product.ItemId;

			//Association association2 = new Association();
			//association2.AssociationType = AssociationTypes.Optional;
			//association2.ItemId = product.ItemId;
			////association2.CatalogItem = product;
			//association2.AssociationGroupId = group2.AssociationGroupId;
			//group2.Associations.Add(association2);

			//product.AssociationGroups.Add(group2);


			ItemAsset asset = new ItemAsset();
			asset.AssetId = String.Format("catalog/{0}", "image");
			asset.AssetType = "file";
			asset.GroupName = "primaryimage";
			asset.ItemId = product.ItemId;
			asset.SortOrder = 1;

			product.ItemAssets.Add(asset);

			var relation = new CategoryItemRelation() { CatalogId = catalogId, CategoryId = categoryId, ItemId = product.ItemId };
			product.CategoryItemRelations.Add(relation);

			return product;
		}
		private static ItemAsset InitializeItem(ItemAsset item, IEnumerable<ImportItem> systemValues)
		{
			if (item == null)
				item = new ItemAsset();
			var itemProperties = item.GetType().GetProperties();
			systemValues.ToList().ForEach(x => SetPropertyValue(item, itemProperties.FirstOrDefault(y => y.Name == x.Name), x.Value));

			return item;
		}
 private static string AssetUrl(ItemAsset asset, bool thumb = false)
 {
     var service = ServiceLocator.Current.GetInstance<IAssetUrl>();
     return service.ResolveUrl(asset.AssetId, thumb);
 }
        public static string ImageThumbnail(this UrlHelper helper, ItemAsset asset)
        {
            const string defaultImage = "blank.png";

            return helper.Content(asset == null ? String.Format("~/Content/themes/default/images/{0}", defaultImage) : AssetUrl(asset, true));
        }