using System; using System.Linq; using Comal.Classes; using InABox.Core; namespace Comal.Stores { internal class RequisitionItemStore : BaseStore { private void UpdateTrackingKanban(RequisitionItem entity) { var requi = new Requisition { ID = entity.RequisitionLink.ID, Filled = entity.RequisitionLink.Filled, Archived = entity.RequisitionLink.Archived }; UpdateTrackingKanban(requi, r => { if (!r.Archived.Equals(DateTime.MinValue)) return KanbanCategory.Complete; if (!r.Filled.Equals(DateTime.MinValue)) return KanbanCategory.Waiting; if (Provider.Query( new Filter(x => x.RequisitionLink.ID).IsEqualTo(r.ID) .And(x=>x.Picked).IsNotEqualTo(DateTime.MinValue), new Columns(x => x.ID) ).Rows.Any() ) return KanbanCategory.InProgress; return KanbanCategory.Open; }); } protected override void AfterSave(RequisitionItem entity) { base.AfterSave(entity); UpdateTrackingKanban(entity); } protected override void AfterDelete(RequisitionItem entity) { base.AfterDelete(entity); UpdateTrackingKanban(entity); } } }