Ejemplo n.º 1
0
        public List <IncidentalFindingGroup> GetAllIncidentalFindingGroup()
        {
            var incidentalFindingGroups = new List <IncidentalFindingGroup>();

            using (var myAdapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var linqMetaData = new LinqMetaData(myAdapter);
                var incidentalFindingGroupEntities = linqMetaData.IncidentalFindingReadingGroup.WithPath(prefetchPath => prefetchPath.Prefetch(incidentalFinding =>
                                                                                                                                               incidentalFinding.IncidentalFindingReadingGroupItem)).ToList();

                //TODO: To move it to Factory/Mapper
                incidentalFindingGroupEntities.ForEach(incidentalFindingGroupEntity =>
                {
                    var incidentalFindingGroup        = new IncidentalFindingGroup(incidentalFindingGroupEntity.GroupId);
                    incidentalFindingGroup.GroupItems = new List <IncidentalFindingGroupItem>();
                    incidentalFindingGroupEntity.IncidentalFindingReadingGroupItem.ToList()
                    .ForEach(
                        findingGroupItem =>
                        incidentalFindingGroup.GroupItems.Add(
                            new IncidentalFindingGroupItem(findingGroupItem.GroupItemId)
                    {
                        Label = findingGroupItem.Label
                    }));

                    incidentalFindingGroups.Add(incidentalFindingGroup);
                });
            }
            return(incidentalFindingGroups);
        }
Ejemplo n.º 2
0
        protected override void MapDomainFields(IncidentalFindingsEntity entity,
                                                IncidentalFinding domainObjectToMapTo)
        {
            domainObjectToMapTo.Id            = entity.IncidentalFindingsId;
            domainObjectToMapTo.Label         = entity.Label;
            domainObjectToMapTo.LocationCount = (int)entity.LocationCount;

            EntityCollection <IncidentalFindingReadingGroupEntity> incidentalFindingReadingGroupEntities =
                entity.
                IncidentalFindingReadingGroupCollectionViaIncidentalFindingIncidentalFindingReadingGroup;

            if (incidentalFindingReadingGroupEntities != null)
            {
                domainObjectToMapTo.IncidentalFindingGroups = new List <IncidentalFindingGroup>();
                foreach (var incidentalFindingReadingGroupEntity in incidentalFindingReadingGroupEntities)
                {
                    var incidentalFindingGroup = new IncidentalFindingGroup(incidentalFindingReadingGroupEntity.GroupId)
                    {
                        GroupItems = new List <IncidentalFindingGroupItem>()
                    };
                    foreach (var incidentalFindingReadingGroupItem in
                             incidentalFindingReadingGroupEntity.IncidentalFindingReadingGroupItem)
                    {
                        var groupItem = new IncidentalFindingGroupItem(incidentalFindingReadingGroupItem.
                                                                       GroupItemId)
                        {
                            Label = incidentalFindingReadingGroupItem.Label
                        };
                        incidentalFindingGroup.GroupItems.Add(groupItem);
                    }
                    domainObjectToMapTo.IncidentalFindingGroups.Add(incidentalFindingGroup);
                }
            }
        }