2014-03-07 2 views
0

Я создаю свой первый спа-центр с угловым и ветром. Так что так хорошо, и я очень доволен прогрессом, который я сделал. Но теперь я застрял в редактировании и сохранении моего продукта сущности (пример класса ниже). Когда я редактирую продукт, я также вызываю связанные продукты, и у меня есть флажок (при сохранении), который говорит «переопределить связанные продукты с той же информацией». Но каков наилучший способ сделать это? Серверная сторона? Должен ли я расширить модель на стороне клиента? Есть ли примеры?Стратегия спасения бризами

продукта:

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 
} 

ответ

0

Захват Изменения Все продукты в Clinent Jquery массив и отправить на стороне сервера ..

Serverside изменить ваш аргумент метода контроллера для продуктов IEnumerable, поэтому вы можете сохранить все изменения в партии

Если вы хотите обновить только значение изменения, используйте HttpPatch на стороне сервера и обновите только измененное значение

 Смежные вопросы

  • Нет связанных вопросов^_^