| 12345678910111213141516171819202122232425262728293031 | using Comal.Classes;using Comal.Stores;using InABox.Core;using System.Collections.Generic;using System.Text;using System;namespace PRSStores;public class StockMovementBatchStore : BaseStore<StockMovementBatch>{    protected override void BeforeDelete(StockMovementBatch entity)    {        base.BeforeDelete(entity);        UpdateStockHoldings(entity);    }    private void UpdateStockHoldings(StockMovementBatch entity)    {        var movements = Provider.Query(            new Filter<StockMovement>(x => x.Batch.ID).IsEqualTo(entity.ID),            Columns.None<StockMovement>().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<StockMovement, Guid>(x => x.ID), StockHoldingStore.Action.Decrease);        }    }}
 |