【问题标题】:Breeze saving strategy微风节省策略
【发布时间】:2014-03-07 06:01:12
【问题描述】:

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

产品:

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
}

【问题讨论】:

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


    【解决方案1】:

    捕获客户端Jquery数组中所有产品的变化并发送到服务器端..

    服务器端将您的控制器方法参数更改为 IEnumerable products ,以便您可以批量保存所有更改

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-21
      相关资源
      最近更新 更多