Webiant Logo Webiant Logo
  1. No results found.

    Try your search with a different keyword or use * as a wildcard.

BaseAttribute.cs

using Nop.Core.Domain.Catalog;
using Nop.Core.Domain.Localization;

namespace Nop.Core.Domain.Attributes;

/// 
/// Represents the base class for attributes
/// 
public abstract partial class BaseAttribute : BaseEntity, ILocalizedEntity
{
    /// 
    /// Gets or sets the name
    /// 
    public string Name { get; set; }

    /// 
    /// Gets or sets a value indicating whether the attribute is required
    /// 
    public bool IsRequired { get; set; }

    /// 
    /// Gets or sets the attribute control type identifier
    /// 
    public int AttributeControlTypeId { get; set; }

    /// 
    /// Gets or sets the display order
    /// 
    public int DisplayOrder { get; set; }

    /// 
    /// Gets the attribute control type
    /// 
    public AttributeControlType AttributeControlType
    {
        get => (AttributeControlType)AttributeControlTypeId;
        set => AttributeControlTypeId = (int)value;
    }

    /// 
    /// A value indicating whether this attribute should have values
    /// 
    public bool ShouldHaveValues
    {
        get
        {
            if (AttributeControlType == AttributeControlType.TextBox ||
                AttributeControlType == AttributeControlType.MultilineTextbox ||
                AttributeControlType == AttributeControlType.Datepicker ||
                AttributeControlType == AttributeControlType.FileUpload)
                return false;

            //other attribute control types support values
            return true;
        }
    }

    /// 
    /// A value indicating whether this attribute can be used as condition for some other attribute
    /// 
    public bool CanBeUsedAsCondition
    {
        get
        {
            if (AttributeControlType == AttributeControlType.ReadonlyCheckboxes ||
                AttributeControlType == AttributeControlType.TextBox ||
                AttributeControlType == AttributeControlType.MultilineTextbox ||
                AttributeControlType == AttributeControlType.Datepicker ||
                AttributeControlType == AttributeControlType.FileUpload)
                return false;

            //other attribute control types support it
            return true;
        }
    }
}