增加项目,分层
This commit is contained in:
1 parent
6e995a5bdb
commit
0a3e5af6a9
234 files changed
+26994
-1
No files matched your search
@@ -0,0 +1,105 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Product.Models.Product.Sku
|
||||
{
|
||||
/// <summary>
|
||||
/// Sku属性
|
||||
/// </summary>
|
||||
public class SkuPropertys : List<SkuProperty>
|
||||
{
|
||||
|
||||
public SkuPropertys()
|
||||
{
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否存在Key
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public bool ContainsKey(string Id)
|
||||
{
|
||||
return Exists(a => a.Id == Id);
|
||||
}
|
||||
/// <summary>
|
||||
/// 添加Sku属性
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="name"></param>
|
||||
public void AddSkuProperty(string id, string name)
|
||||
{
|
||||
if (!ContainsKey(id))
|
||||
{
|
||||
this.Add(new SkuProperty
|
||||
{
|
||||
Id = id,
|
||||
Name = name,
|
||||
Values = new List<SkuPropertyItem>()
|
||||
});
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 添加Sku属性 包含值
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="propertyItem"></param>
|
||||
public void AddSkuPropertyItem(string id, SkuPropertyItem propertyItem)
|
||||
{
|
||||
if (propertyItem != null)
|
||||
{
|
||||
var item = GetPropertyById(id);
|
||||
if (!item.Values.Exists(a => a.Id == propertyItem.Id))
|
||||
{
|
||||
item.Values.Add(propertyItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
//public void AddSkuProperty(string id, string name, SkuPropertyItem propertyItem)
|
||||
//{
|
||||
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 获取Sku属性值
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="itemname"></param>
|
||||
/// <returns></returns>
|
||||
public SkuMapProperty GetSkuMapProperty(string name, string itemname)
|
||||
{
|
||||
SkuProperty p = this.FirstOrDefault(a => a.Name == name);
|
||||
if (p != null)
|
||||
{
|
||||
var item = p.Values.FirstOrDefault(a => a.Name == itemname);
|
||||
return new SkuMapProperty()
|
||||
{
|
||||
Id = p.Id,
|
||||
Name = p.Name,
|
||||
Item = item
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取值
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public SkuProperty GetPropertyById(string Id)
|
||||
{
|
||||
if (ContainsKey(Id))
|
||||
{
|
||||
SkuProperty p = this.FirstOrDefault(a => a.Id == Id);
|
||||
return p;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user