﻿using Radial;
using Radial.Persist;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WishStore.Models.Search
{
    /// <summary>
    /// ProductFilter.
    /// </summary>
    public sealed class ProductFilter
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ProductFilter"/> class.
        /// </summary>
        public ProductFilter()
        {
            Properties = new Dictionary<string, string>();
            IsDelete = false;
        }

        /// <summary>
        /// Gets or sets the identifier.
        /// </summary>
        public string Id { get; set; }

        /// <summary>
        /// Gets or sets the category identifier.
        /// </summary>
        public string CategoryId { get; set; }

        /// <summary>
        /// Gets or sets the kind identifier.
        /// </summary>
        public string KindId { get; set; }

        /// <summary>
        /// Gets or sets the keyword.
        /// </summary>
        public string Keyword { get; set; }


        /// <summary>
        /// Gets or sets the spec group.
        /// </summary>
        public string SpecGroup { get; set; }

        /// <summary>
        /// Gets or sets the properties (key=property id, value=property value).
        /// </summary>
        public IDictionary<string, string> Properties { get; set; }

        /// <summary>
        /// Gets or sets the is on sale.
        /// </summary>
        public bool? IsOnSale { get; set; }


        /// <summary>
        /// Gets or sets the is delete.
        /// </summary>
        public bool? IsDelete { get; set; }

        /// <summary>
        /// 获取或设置是否返回额外的搜索结果
        /// </summary>
        public bool WithExtraData { get; set; }

        /// <summary>
        /// 获取或设置每页显示的数量或返回的记录数
        /// </summary>
        public int? PageSize { get; set; }

        /// <summary>
        /// 获取或设置页码
        /// </summary>
        public int? PageIndex { get; set; }
    }


    /// <summary>
    /// ProductResult.
    /// </summary>
    public sealed class ProductResult
    {
        /// <summary>
        /// 获取或设置查询返回的对象列表
        /// </summary>
        public IList<Product> Objects { get; set; }

        /// <summary>
        /// 获取或设置对象总数量（仅当分页查询时有效）
        /// </summary>
        public int? ObjectTotal { get; set; }

        #region Extra Data


        /// <summary>
        /// Gets or sets the categories.
        /// </summary>
        public IList<Category> Categories { get; set; }

        /// <summary>
        /// Gets or sets the kinds.
        /// </summary>
        public IList<Kind> Kinds { get; set; }

        /// <summary>
        /// Gets or sets the price range.
        /// </summary>
        public RangeValue<decimal> PriceRange { get; set; }


        /// <summary>
        /// Gets or sets the properties.
        /// </summary>
        public IDictionary<Property, string[]> Properties { get; set; }

        #endregion
    }

    /// <summary>
    /// ProductSort.
    /// </summary>
    public sealed class ProductSort
    {
        /// <summary>
        /// Gets or sets the unit price.
        /// </summary>
        public SortDirection? UnitPrice { get; set; }
    }
}
