Esempio n. 1
0
		/// <summary>
		/// Initializes a new instance of the <see cref="FlashModel"/> class.
		/// </summary>
		/// <param name="item">The item.</param>
        public FlashModel(DynamicContentItem item)
        {
            foreach (var prop in item.PropertyValues)
            {
                if (String.Equals(prop.Name, "Height", StringComparison.InvariantCultureIgnoreCase))
                {
                    Height = prop.IntegerValue;
                }

                if (String.Equals(prop.Name, "Width", StringComparison.InvariantCultureIgnoreCase))
                {
                    Width = prop.IntegerValue;
                }

                if (String.Equals(prop.Name, "ClassId", StringComparison.InvariantCultureIgnoreCase))
                {
                    ClassId = prop.LongTextValue;
                }

                if (String.Equals(prop.Name, "Src", StringComparison.InvariantCultureIgnoreCase))
                {
                    Src = prop.LongTextValue;
                }
            }
        }
        public static TestContentItemsBuilder BuildsContentItems()
        {
            var contentItem1 = new DynamicContentItem()
            {
                Name = "default_contentItem_1",
                Description = "description_1",
                IsMultilingual = true
            };

            var contentItem2 = new DynamicContentItem()
            {
                Name = "default_contentItem_2",
                Description = "description_2",
                IsMultilingual = false
            };

            var contentItem3 = new DynamicContentItem()
            {
                Name = "default_contentItem_2",
                Description = "description_2",
                IsMultilingual = false
            };

            return new TestContentItemsBuilder(new List<DynamicContentItem>() {contentItem1, contentItem2, contentItem3});
        }
		/// <summary>
		/// Initializes a new instance of the <see cref="RawHtmlModel"/> class.
		/// </summary>
		/// <param name="item">The item.</param>
        public RawHtmlModel(DynamicContentItem item)
		{
		    foreach (var prop in item.PropertyValues.Where(prop => String.Equals(prop.Name, "RawHtml", StringComparison.InvariantCultureIgnoreCase)))
		    {
		        Html = prop.LongTextValue;
		        break;
		    }
		}
        public TestContentPublishingBuilder WithContentItems(DynamicContentItem[] contentItems)
        {
	        foreach (var publishingGroupContentItem in contentItems.Select(dynamicContentItem => new PublishingGroupContentItem
		        {
			        DynamicContentPublishingGroupId = _contentPublishingGroup.DynamicContentPublishingGroupId,
			        DynamicContentItemId = dynamicContentItem.DynamicContentItemId
		        }))
	        {
		        _contentPublishingGroup.ContentItems.Add(publishingGroupContentItem);
	        }

	        return this;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="RawHtmlModel"/> class.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="context"></param>
        public RazorHtmlModel(DynamicContentItem item, ViewContext context) : base(item)
        {
            if (string.IsNullOrWhiteSpace(Html))
            {
                foreach (
                    var prop in
                        item.PropertyValues.Where(
                            prop => String.Equals(prop.Name, "RazorHtml", StringComparison.InvariantCultureIgnoreCase)))
                {
                    Html = prop.LongTextValue;
                    break;
                }
            }

            Html = ViewRenderer.RenderTemplate(Html, this, context.Controller.ControllerContext);
        }
		public CreateDynamicContentItemViewModel(
			IViewModelsFactory<IPropertyEditViewModel> propertyEditVmFactory,
			IViewModelsFactory<IDynamicContentItemOverviewStepViewModel> overviewVmFactory,
			IViewModelsFactory<IDynamicContentItemPropertiesStepViewModel> propertiesVmFactory,
			IDynamicContentEntityFactory entityFactory, DynamicContentItem item)
		{
			_parentVM = this;
			_entityFactory = entityFactory;
			_propertyEditVmFactory = propertyEditVmFactory;

			var itemParameter = new KeyValuePair<string, object>("item", item);
			var parentVMParameter = new KeyValuePair<string, object>("parentVM", this);
			var entityFactoryParameter = new KeyValuePair<string, object>("entityFactory", _entityFactory);
			var propertyEditVMParameter = new KeyValuePair<string, object>("propertyEditVmFactory", propertyEditVmFactory);
			RegisterStep(overviewVmFactory.GetViewModelInstance(itemParameter, parentVMParameter, entityFactoryParameter));
			RegisterStep(propertiesVmFactory.GetViewModelInstance(itemParameter, parentVMParameter, entityFactoryParameter, propertyEditVMParameter));

		}
		protected CreateDynamicContentItemViewModel(
			DynamicContentItem item,
			CreateDynamicContentItemViewModel _parentViewModel,
			IDynamicContentEntityFactory entityFactory,
			IViewModelsFactory<IPropertyEditViewModel> propertyEditVmFactory)
		{
			_parentVM = _parentViewModel;

			InnerItem = item;
			InnerItem.PropertyChanged += InnerItem_PropertyChanged;
			_propertyEditVmFactory = propertyEditVmFactory;


			if (this is IDynamicContentItemPropertiesStepViewModel)
			{
				_entityFactory = entityFactory;
				PropertyValueEditCommand = new DelegateCommand<DynamicContentItemProperty>(RaisePropertyValueEditInteractionRequest, x => x != null);
				PropertyValueDeleteCommand = new DelegateCommand<DynamicContentItemProperty>(RaisePropertyValueDeleteInteractionRequest, x => x != null);
				CommonConfirmRequest = new InteractionRequest<Confirmation>();
			}
		}
		public DynamicContentItemPropertiesStepViewModel(
			DynamicContentItem item,
			CreateDynamicContentItemViewModel parentVM,
			IDynamicContentEntityFactory entityFactory,
			IViewModelsFactory<IPropertyEditViewModel> propertyEditVmFactory)
			: base(item, parentVM, entityFactory, propertyEditVmFactory)
		{

		}
		public DynamicContentItemOverviewStepViewModel(DynamicContentItem item, CreateDynamicContentItemViewModel parentVM, IDynamicContentEntityFactory entityFactory)
			: base(item, parentVM, entityFactory, null)
		{

		}
        /// <summary>
        /// Initializes a new instance of the <see cref="CategoryUrlModel"/> class.
        /// </summary>
        /// <param name="item">The item.</param>
        public CategoryUrlModel(DynamicContentItem item)
        {
            foreach (var prop in item.PropertyValues)
            {
                if (String.Equals(prop.Name, "CategoryCode", StringComparison.InvariantCultureIgnoreCase))
                {
                    CategoryCode = prop.LongTextValue;
                }

                if (String.Equals(prop.Name, "Title", StringComparison.InvariantCultureIgnoreCase))
                {
                    Title = prop.LongTextValue;
                }

                if (String.Equals(prop.Name, "SortField", StringComparison.InvariantCultureIgnoreCase))
                {
                    SortField = prop.ShortTextValue;
                }

                if (String.Equals(prop.Name, "ItemCount", StringComparison.InvariantCultureIgnoreCase))
                {
                    ItemCount = prop.IntegerValue;
                }

                if (String.Equals(prop.Name, "NewItems", StringComparison.InvariantCultureIgnoreCase))
                {
                    NewItemsOnly = prop.BooleanValue;
                }
            }
        }
		/// <summary>
		/// Initializes a new instance of the <see cref="ProductWithImageAndPriceModel"/> class.
		/// </summary>
		/// <param name="item">The item.</param>
        public ProductWithImageAndPriceModel(DynamicContentItem item)
        {
            foreach (var prop in item.PropertyValues)
            {
                if (String.Equals(prop.Name, "ProductCode", StringComparison.InvariantCultureIgnoreCase))
                {
                    ProductCode = prop.LongTextValue;
                }
            }
        }
		/// <summary>
		/// Initializes a new instance of the <see cref="BannerModel" /> class.
		/// </summary>
		/// <param name="items">The items.</param>
        public BannerModel(DynamicContentItem[] items)
        {
            Items = items;
        }
		/// <summary>
		/// Initializes a new instance of the <see cref="ImageClickableModel"/> class.
		/// </summary>
		/// <param name="item">The item.</param>
        public ImageClickableModel(DynamicContentItem item)
        {
            foreach (var prop in item.PropertyValues)
            {
                if (String.Equals(prop.Name, "ImageUrl", StringComparison.InvariantCultureIgnoreCase))
                {
                    ImageUrl = prop.LongTextValue;
                }

                if (String.Equals(prop.Name, "TargetUrl", StringComparison.InvariantCultureIgnoreCase))
                {
                    TargetUrl = prop.LongTextValue;
                }
            }
        }