示例#1
0
        public DTO.Field Resolve(Field field)
        {
            var dto  = Projections.Field.ToDto(field);
            var meta = _metadata.Find <DataEntryField>(field.DataEntryFieldId);

            InjectMetadata(dto, meta);

            return(dto);
        }
        public Guid Create(Guid agencyId, string name, Guid dataEntryContractId, TemplateDetails details)
        {
            // Commented out until Module Permissions are Fixed. :(
            //RequireModuleAccess(ModuleType.DataEntryDesigner);

            var agency       = _administrationUnitOfWork.Find <Agency>(agencyId);
            var contractMeta = _metadataUnitOfWork.Find <DataEntryContract>(dataEntryContractId);

            // Create the new Template
            var template = agency.CreateTemplate(contractMeta.Id, contractMeta.ModuleType, name);

            // Map Details
            details.MapInto(template);

            // Commit
            _administrationUnitOfWork.Commit();

            return(template.Id);
        }
        /// <summary>
        /// Resolve the Metadata for a Section.
        /// Metadata must be injected into the Section DTO
        /// because it is not persisted in the Section Domain Object.
        /// </summary>
        public DTO.Section Resolve(Section section)
        {
            var dto  = Projections.Section.ToDto(section);
            var meta = _metadata.Find <DataEntrySection>(section.DataEntrySectionId);

            InjectMetadata(dto, meta);

            // Process Section Fields
            foreach (var field in section.Fields.OrderBy(x => x.OrderBy).Where(x => x.SubSectionId == Guid.Empty))
            {
                dto.Fields.Add(_fieldMetadataResolver.Resolve(field));
            }



            // Process Sub Sections
            foreach (var subSection in section.SubSections.OrderBy(x => x.OrderBy))
            {
                var subSectionId  = subSection.Id;
                var subSectionDto = new DTO.SubSection()
                {
                    Fields  = new List <DTO.Field>(),
                    Label   = subSection.Label,
                    OrderBy = subSection.OrderBy
                };

                // Add the SubSection to the DTO.
                dto.SubSections.Add(subSectionDto);

                // Process SubSection Fields
                foreach (var field in section.Fields.OrderBy(x => x.OrderBy).Where(x => x.SubSectionId == subSectionId))
                {
                    subSectionDto.Fields.Add(_fieldMetadataResolver.Resolve(field));
                }
            }

            return(dto);
        }