35 lines
884 B
C#
35 lines
884 B
C#
using Store.Product.Models.Product.Image;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Store.Product.Models.Product
|
|
{
|
|
/// <summary>
|
|
/// 主图集合
|
|
/// </summary>
|
|
public class MainImageCollection : List<ProductImage>
|
|
{
|
|
/// <summary>
|
|
/// 随机排序
|
|
/// </summary>
|
|
public void RandomSort()
|
|
{
|
|
Random random = new Random();
|
|
List<ProductImage> newList = new List<ProductImage>();
|
|
foreach (ProductImage item in this.Take(4))
|
|
{
|
|
newList.Insert(random.Next(newList.Count + 1), item);
|
|
}
|
|
if (this.Count == 5)
|
|
{
|
|
newList.Add(this.Last());
|
|
}
|
|
this.Clear();
|
|
this.AddRange(newList);
|
|
}
|
|
}
|
|
}
|