微风节约策略

时间:2014-03-07 06:01:12

标签: angularjs breeze asp.net-web-api2

我正在创造我的第一个带有棱角和微风的水疗中心。所以非常好,我对我所取得的进步感到非常满意。但现在我坚持编辑并保存我的实体产品(下面的示例类)。当我编辑产品时,我也会调用相关产品,并且我有一个复选框(保存时),上面写着“覆盖相同信息的相关产品”。但是最好的方法是什么?服务器端?我应该在客户端扩展模型吗?有可用的例子吗?

产品:

public class Product
{
    #region Fields

    private ICollection<ProductCategory> _productCategories;
    private ICollection<ProductManufacturer> _productManufacturers;
    private ICollection<ProductPicture> _productPictures;
    private ICollection<ProductSpecificationAttribute> _productSpecificationAttributes;
    private ICollection<ProductTierPrice> _productTierPrices;

    #endregion Fields

    #region Properties

    public int Id { get; set; }
    public ProductType ProductType { get; set; }
    public int ParentGroupedProductId { get; set; }
    public bool VisibleIndividually { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
    public string MetaTitle { get; set; }
    public string MetaDescription { get; set; }
    public int DisplayOrder { get; set; }
    public bool LimitedToStores { get; set; }
    public string Sku { get; set; }
    public string UniqueCode { get; set; }
    public decimal Price { get; set; }
    public decimal OldPrice { get; set; }
    public decimal? SpecialPrice { get; set; }
    public DateTime? SpecialPriceStartDateTimeUtc { get; set; }
    public DateTime? SpecialPriceEndDateTimeUtc { get; set; }
    public decimal DiscountPercentage { get; set; }
    public bool HasTierPrices { get; set; }
    public TaxRate TaxRate { get; set; }
    public bool SyncToShop { get; set; }
    public bool Deleted { get; set; }
    public bool Locked { get; set; }
    public State State { get; set; }
    public DateTime? DateChanged { get; set; }
    public DateTime? DateCreated { get; set; }

    #endregion Properties

    #region Mapping

    public virtual ICollection<ProductCategory> ProductCategories
    {
        get { return _productCategories ?? (_productCategories = new List<ProductCategory>()); }
        protected set { _productCategories = value; }
    }

    public virtual ICollection<ProductManufacturer> ProductManufacturers
    {
        get { return _productManufacturers ?? (_productManufacturers = new List<ProductManufacturer>()); }
        protected set { _productManufacturers = value; }
    }

    public virtual ICollection<ProductPicture> ProductPictures
    {
        get { return _productPictures ?? (_productPictures = new List<ProductPicture>()); }
        protected set { _productPictures = value; }
    }

    public virtual ICollection<ProductSpecificationAttribute> ProductSpecificationAttributes
    {
        get { return _productSpecificationAttributes ?? (_productSpecificationAttributes = new List<ProductSpecificationAttribute>()); }
        protected set { _productSpecificationAttributes = value; }
    }

    public virtual ICollection<ProductTierPrice> ProductTierPrices
    {
        get { return _productTierPrices ?? (_productTierPrices = new List<ProductTierPrice>()); }
        protected set { _productTierPrices = value; }
    }

    #endregion Mapping
}

相关产品:

public class RelatedProduct
{
    #region Fields

    #endregion Fields

    #region Properties

    public int Id { get; set; }
    public int ProductId1 { get; set; }
    public int ProductId2 { get; set; }
    public int DisplayOrder { get; set; }
    public State State { get; set; }

    #endregion Properties

    //#region Mapping

    //public virtual Product Product1 { get; set; }
    //public virtual Product Product2 { get; set; }

    //#endregion Mapping
}

1 个答案:

答案 0 :(得分:0)

捕获Clinent Jquery数组中所有产品的更改并发送到服务器端..

Serverside将您的控制器方法参数更改为IEnumerable产品,因此您可以保存批处理中的所有更改

如果您只想更新更改值,请在服务器端使用HttpPatch并仅更新更改的值