| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 | 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<Setout>    {        protected override void AfterSave(Setout entity)        {            if (entity.Group.ID != Guid.Empty)            {                var table = Provider.Query<SetoutGroup>(new Filter<SetoutGroup>(x => x.ID).IsEqualTo(entity.Group.ID)                    .And(x => x.OptimizationDocument.ID).IsNotEqualTo(Guid.Empty),                    new Columns<SetoutGroup>(x => x.OptimizationDocument.ID));                if (!table.Rows.Any())                    return;                var docID = table.Rows.FirstOrDefault().Get<SetoutGroup, Guid>(x => x.OptimizationDocument.ID);                if (docID == Guid.Empty)                    return;                List<Guid> ids = new List<Guid>();                var docsTable = Provider.Query<SetoutDocument>(                    new Filter<SetoutDocument>(x => x.EntityLink.ID).IsEqualTo(entity.ID),                    new Columns<SetoutDocument>(x => x.DocumentLink.ID)                    );                foreach (var row in docsTable.Rows)                    ids.Add(row.Get<SetoutDocument, Guid>(x => x.DocumentLink.ID));                if (!ids.Contains(docID))                {                    var setoutdoc = new SetoutDocument();                    setoutdoc.EntityLink.ID = entity.ID;                    setoutdoc.DocumentLink.ID = docID;                    FindSubStore<SetoutDocument>().Save(setoutdoc, "Added optimsation document from Group");                }            }            base.AfterSave(entity);        }        protected override void BeforeDelete(Setout entity)        {            UnlinkTrackingKanban<SetoutKanban, Setout, SetoutLink>(entity);        }    }}
 |