using Comal.Classes; using Comal.Stores; using InABox.Core; using System.Collections.Generic; using System.Text; using System; namespace PRSStores; public class StockMovementBatchStore : BaseStore { protected override void BeforeDelete(StockMovementBatch entity) { base.BeforeDelete(entity); UpdateStockHoldings(entity); } private void UpdateStockHoldings(StockMovementBatch entity) { var movements = Provider.Query( new Filter(x => x.Batch.ID).IsEqualTo(entity.ID), Columns.None().Add(x => x.ID)); foreach(var row in movements.Rows) { // We need to do this in before delete, because aotherwise we wont have the data // that we need to pull to properly update the stockholdings StockHoldingStore.UpdateStockHolding(this, row.Get(x => x.ID), StockHoldingStore.Action.Decrease); } } }