using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using System.Linq;
namespace BBWY.Client.Models
{
///
/// 采购商品
///
public class PurchaseSchemeProduct : NotifyObject
{
private string purchaseUrl;
private string purchaseProductId;
private bool isEditing;
///
/// 采购商品和采购方案的关系Id
///
public long Id { get; set; }
public string ProductId { get; set; }
public string SkuId { get; set; }
public string PurchaseUrl { get => purchaseUrl; set { Set(ref purchaseUrl, value); } }
public string PurchaseProductId { get => purchaseProductId; set => purchaseProductId = value; }
public bool IsEditing { get => isEditing; set { Set(ref isEditing, value); } }
public IList SkuList { get; set; }
public IList PurchaseSchemeProductSkuList { get; set; }
public List SelectedSkuIdList { get; set; }
public int PurchaseSkuCount
{
get { return SelectedSkuIdList.Count(); }
}
public PurchaseSchemeProduct()
{
SkuList = new ObservableCollection();
PurchaseSchemeProductSkuList = new ObservableCollection();
SelectedSkuIdList = new List();
}
///
///
///
///
/// 是否转换方案中已选的sku
///
public static PurchaseSchemeProduct Convert(PurchaseSchemeProductResponse apiModel)
{
var model = new PurchaseSchemeProduct()
{
Id = apiModel.Id,
ProductId = apiModel.ProductId,
SkuId = apiModel.SkuId,
PurchaseProductId = apiModel.PurchaseProductId,
PurchaseUrl = apiModel.PurchaseUrl
};
model.SelectedSkuIdList.AddRange(apiModel.PurchaseSchemeProductSkuList.Select(s => s.PurchaseSkuId));
return model;
}
}
}