public static ObjectModel ConvertToModelFromLaborDetailObject(LaborDetailObject.Item laborDetailObject, int Year, IDirectoryManager directoryManager)
        {
            var         load       = laborDetailObject.Loading.FirstOrDefault();
            ObjectModel objectFrom = ConvertToModelFromLaborDetailObjectItem(load, Year, directoryManager);

            if (objectFrom != null)
            {
                objectFrom.LaborDetailObjectID         = laborDetailObject.Identity;
                objectFrom.LaborDetailObjectItemFromID = load.Identity;
            }

            var         unload   = laborDetailObject.Unloading.FirstOrDefault();
            ObjectModel objectTo = ConvertToModelFromLaborDetailObjectItem(unload, Year, directoryManager);

            if (objectTo != null)
            {
                objectTo.LaborDetailObjectID       = laborDetailObject.Identity;
                objectTo.LaborDetailObjectItemToID = unload.Identity;
            }

            if (objectFrom != null && objectTo != null)
            {
                return(ConvertToModel(objectFrom, objectTo));
            }

            return(objectFrom);
        }
        public override void ConvertDataToDTO <T>(T item)
        {
            if (typeof(T) == typeof(LaborDetail.Item))
            {
                var model = (item as LaborDetail.Item);

                model.Objects = new List <LaborDetailObject.Item>();
                foreach (var obj in ObjectCollection)
                {
                    LaborDetailObject.Item objdb = new LaborDetailObject.Item();
                    model.Objects.Add(objdb);

                    objdb.Identity = obj.LaborDetailObjectID;
                    objdb.Loading  = obj.ObjectId.HasValue ? new List <LaborDetailObjectItem.Item>()
                    {
                        new LaborDetailObjectItem.Item()
                        {
                            Identity = obj.LaborDetailObjectItemFromID, Outline = new Argo.DataAccess.All.Models.Outline.ListItem()
                            {
                                Identity = obj.ObjectId.Value
                            }
                        }
                    } : null;

                    if (!IsSingleObject)
                    {
                        objdb.Unloading = obj.ToObjectId.HasValue ? new List <LaborDetailObjectItem.Item>()
                        {
                            new LaborDetailObjectItem.Item()
                            {
                                Identity = obj.LaborDetailObjectItemToID, Outline = new Argo.DataAccess.All.Models.Outline.ListItem()
                                {
                                    Identity = obj.ToObjectId.Value
                                }
                            }
                        } : null;
                    }
                }
            }
        }