using Comal.Classes; using System; using InABox.Core; using System.Collections.Generic; using System.Linq; using Syncfusion.Pdf.Parsing; using System.Drawing; using System.IO; using System.Drawing.Imaging; namespace Comal.Stores { public class SetoutStore : BaseStore { protected override void AfterSave(Setout entity) { if (entity.Group.ID != Guid.Empty) { var table = Provider.Query(new Filter(x => x.ID).IsEqualTo(entity.Group.ID) .And(x => x.OptimizationDocument.ID).IsNotEqualTo(Guid.Empty), new Columns(x => x.OptimizationDocument.ID)); if (!table.Rows.Any()) return; var docID = table.Rows.FirstOrDefault().Get(x => x.OptimizationDocument.ID); if (docID == Guid.Empty) return; List ids = new List(); var docsTable = Provider.Query( new Filter(x => x.EntityLink.ID).IsEqualTo(entity.ID), new Columns(x => x.DocumentLink.ID) ); foreach (var row in docsTable.Rows) ids.Add(row.Get(x => x.DocumentLink.ID)); if (!ids.Contains(docID)) { var setoutdoc = new SetoutDocument(); setoutdoc.EntityLink.ID = entity.ID; setoutdoc.DocumentLink.ID = docID; FindSubStore().Save(setoutdoc, "Added optimsation document from Group"); } } base.AfterSave(entity); } protected override void BeforeDelete(Setout entity) { UnlinkTrackingKanban(entity); } } }