public Tcas(Cas ecas)
 {
     list = new KudanTcaClient(
         new TcaClient(
             new McaClient(
                 ecas
                 )
             )
         )
            .CreateItems()
            .ToList();
 }
        private void ProcessItem(ICa eca)
        {
            var tdmsObjects    = GetTdmsObjects(eca.Id).ToList();
            var noObjectsFound = (tdmsObjects.Count == 0);

            if (noObjectsFound)
            {
                CreateTdmsObject(eca);
                return;
            }
            var oldItems          = tdmsObjects.Select(t => t.ToRestoredTdmsCorrectionAction()).ToList();
            var noObjectsRestored = (oldItems.Count == 0);

            if (noObjectsRestored)
            {
                CreateTdmsObject(eca);
                return;
            }

            var youthItems = new KudanTcaClient(new TcaClient(new McaClient(new List <ICa>()
            {
                eca
            }))).CreateItems();

            var pairs = new IntersectIdMapItemsFamily(oldItems, youthItems).CreateItems();

            var theVersion = this.GetMaxVersion(tdmsObjects) + 1;

            var itemsToUpdate = pairs.Select(p => p.youthItem);
            var itemsNew      = youthItems.Except(itemsToUpdate, new CaIdAndSystemsEqualityComparer());

            new CreateFromTcaItemsBehavior(client, itemsNew).ProcessItems();

            foreach (var pair in pairs)
            {
                var behavior = new UpdateItemsFromTdmsCorrectionActionsBehavior(client, new List <ICa>()
                {
                    pair.youthItem
                }, ((RestoredTdmsCorrectionAction)pair.oldItem).tdmsObject, theVersion);
                behavior.ProcessItems();
            }
        }