Esempio n. 1
0
        public override VmChannelConnectionOutput TranslateEntityToVm(ServiceServiceChannel entity)
        {
            var service       = VersioningManager.ApplyPublishingStatusFilterFallback(entity.Service.Versions);
            var serviceTypeId = service.StatutoryServiceGeneralDescriptionId.IsAssigned()
                ? VersioningManager.ApplyPublishingStatusFilterFallback(service.StatutoryServiceGeneralDescription.Versions).TypeId
                : service.TypeId;
            var connectionId = entity.ServiceId.ToString() + service.UnificRootId.ToString();

            return(CreateEntityViewModelDefinition(entity)
                   .AddNavigation(i => connectionId, o => o.ConnectionId)
                   .AddSimple(i => service.Id, o => o.Id)
                   .AddSimple(i => service.UnificRootId, o => o.UnificRootId)
                   .AddCollection <ILanguageAvailability, VmLanguageAvailabilityInfo>(i => service.LanguageAvailabilities, o => o.LanguagesAvailabilities)
                   .AddSimple(i => serviceTypeId.Value, o => o.ServiceTypeId)
                   .AddNavigation(i => typesCache.GetByValue <ServiceType>(serviceTypeId.Value), o => o.ServiceType)
                   .AddSimple(i => service.OrganizationId, o => o.OrganizationId)
                   .AddSimple(i => i.Modified, o => o.Modified)
                   .AddNavigation(i => i.ModifiedBy, o => o.ModifiedBy)
                   .AddDictionary(i => service.ServiceNames.Where(j => j.TypeId == typesCache.Get <NameType>(NameTypeEnum.Name.ToString())), o => o.Name,
                                  i => languageCache.GetByValueEnum(i.LocalizationId).ToString())
                   .AddNavigation(i => i, o => o.BasicInformation)
                   .AddNavigation(i => i, o => o.DigitalAuthorization)
                   .AddNavigation(i => i, o => o.AstiDetails)
                   .GetFinal());
        }
 public override VmChannelRelationListItem TranslateEntityToVm(ServiceServiceChannel entity)
 {
     return(CreateEntityViewModelDefinition <VmChannelRelationListItem>(entity)
            .AddNavigation(i => Guid.NewGuid().ToString(), o => o.Id)
            .AddSimple(i => i.ServiceId, o => o.Service)
            .AddNavigation(i => VersioningManager.ApplyPublishingStatusFilterFallback(i.ServiceChannel.Versions), o => o.ConnectedChannel)
            .GetFinal());
 }
Esempio n. 3
0
 public override VmConnection TranslateEntityToVm(ServiceServiceChannel entity)
 {
     return(CreateEntityViewModelDefinition(entity)
            .AddNavigation(i => i.ServiceChannelId.ToString() + i.ServiceId.ToString(), o => o.Id)
            .AddSimple(i => entity.RequestedForServiceChannel ?? VersioningManager.ApplyPublishingStatusFilterFallback(i.ServiceChannel.Versions)?.Id ?? Guid.Empty, o => o.ChannelId)
            .AddSimple(i => VersioningManager.ApplyPublishingStatusFilterFallback(i.Service.Versions)?.Id ?? Guid.Empty, o => o.ServiceId)
            .AddSimple(i => i.Modified, o => o.Modified)
            .AddNavigation(i => i.ModifiedBy, o => o.ModifiedBy)
            .GetFinal());
 }
 public override VmGeneralDescription TranslateEntityToVm(StatutoryServiceGeneralDescription entity)
 {
     if (entity == null)
     {
         return(null);
     }
     SetLanguage(LanguageCode.fi);
     return(CreateEntityViewModelDefinition(entity)
            .AddPartial(i => VersioningManager.ApplyPublishingStatusFilterFallback(i.Versions))
            .AddSimple(i => i.Id, o => o.Id)
            .GetFinal());
 }
        public override VmServiceListItem TranslateEntityToVm(ServiceVersioned entity)
        {
            var definition = CreateEntityViewModelDefinition <VmServiceListItem>(entity)
                             .AddNavigation(i => VersioningManager.ApplyLanguageFilterFallback(i.ServiceNames.Where(k => k.TypeId == typesCache.Get <NameType>(NameTypeEnum.Name.ToString())), RequestLanguageId)?.Name ?? "N/A", o => o.Name)
                             .AddSimple(i => i.PublishingStatusId, o => o.PublishingStatusId)
                             .AddSimple(i => i.UnificRootId, o => o.UnificRootId)
                             .AddSimple(i => i.TypeId ?? VersioningManager.ApplyPublishingStatusFilterFallback(i.StatutoryServiceGeneralDescription?.Versions).TypeId, o => o.ServiceTypeId)
                             .AddNavigation(
                i =>
                typesCache.GetByValue <ServiceType>(i.TypeId ?? VersioningManager.ApplyPublishingStatusFilterFallback(i.StatutoryServiceGeneralDescription?.Versions).TypeId),
                o => o.ServiceType)
                             .AddCollection(i =>
                                            (VersioningManager.ApplyPublishingStatusFilterFallback(i.StatutoryServiceGeneralDescription?.Versions) != null
                            ? i.ServiceOntologyTerms.Select(x => x.OntologyTerm)
                                             .Union(
                                                 VersioningManager.ApplyPublishingStatusFilterFallback(i.StatutoryServiceGeneralDescription?.Versions).OntologyTerms.Select(x => x.OntologyTerm))
                            : i.ServiceOntologyTerms.Select(x => x.OntologyTerm)).Cast <IFintoItemBase>()
                                            , o => o.OntologyTerms)
                             .AddSimple(i => i.Modified, o => o.Modified)
                             .AddSimpleList(i =>
                                            VersioningManager.ApplyPublishingStatusFilterFallback(i.StatutoryServiceGeneralDescription?.Versions) != null
                            ? i.ServiceServiceClasses.Select(s => s.ServiceClassId)
                                            .Union(
                                                VersioningManager.ApplyPublishingStatusFilterFallback(i.StatutoryServiceGeneralDescription?.Versions)
                                                .ServiceClasses.Select(s => s.ServiceClassId))
                            : i.ServiceServiceClasses.Select(s => s.ServiceClassId)
                                            , o => o.ServiceClasses)
                             .AddCollection <ILanguageAvailability, VmLanguageAvailabilityInfo>(i => i.LanguageAvailabilities.OrderBy(x => x.Language.OrderNumber), o => o.LanguagesAvailabilities)
                             .AddNavigation(i => i.Versioning, o => o.Version)
                             .AddSimpleList(i => i.OrganizationServices.Select(x => x.OrganizationId).Union(new List <Guid> {
                i.OrganizationId
            }), o => o.Organizations)
                             .AddSimpleList(i => i.ServiceProducers.Select(x => x.Id), o => o.Producers);

            if (entity.UnificRoot != null)
            {
                definition.AddSimple(i => i.UnificRoot.ServiceServiceChannels.Count(
                                         x => x.ServiceChannel.Versions.Any(j => j.PublishingStatusId == typesCache.Get <PublishingStatusType>(PublishingStatus.Published.ToString()) ||
                                                                            j.PublishingStatusId == typesCache.Get <PublishingStatusType>(PublishingStatus.Draft.ToString()))),
                                     o => o.ConnectedChannelsCount);
            }

            var model = definition.GetFinal();

            if (!model.Name.Any())
            {
                definition.AddDictionary(i => i.ServiceNames, o => o.Name, k => languageCache.GetByValue(k.LocalizationId));
            }

            return(model);
        }
        public override VmChannelRelation TranslateEntityToVm(ServiceServiceChannel entity)
        {
            var model = CreateEntityViewModelDefinition <VmChannelRelation>(entity)
                        .AddSimple(i => i.ServiceId, o => o.Service)
                        .AddSimple(i => i.ChargeTypeId, o => o.ChargeType)
                        .AddSimple(i => true, o => o.isLoaded)
                        .AddCollection(i => i.ServiceServiceChannelDigitalAuthorizations.Select(x => x.DigitalAuthorization as IFintoItemBase), output => output.DigitalAuthorizations)
                        .AddNavigation(i => VersioningManager.ApplyPublishingStatusFilterFallback(i.ServiceChannel.Versions), o => o.ConnectedChannel)
//                .AddLocalizable(i => GetDescription(i), output => output.Description)
//                .AddLocalizable(i => GetDescription(i), output => output.ChargeTypeAdditionalInformation)
                        .GetFinal();

            model.Texts = GetDescriptions(entity);
            return(model);
        }
        public override VmServiceRelationListItem TranslateEntityToVm(ServiceVersioned entity)
        {
            var langAvailabilities = entity.LanguageAvailabilities ?? new List <ServiceLanguageAvailability>();

            langAvailabilities = langAvailabilities.Where(i => i.Language != null).ToList();
            return(CreateEntityViewModelDefinition <VmServiceRelationListItem>(entity)
                   .AddNavigation(i => VersioningManager.ApplyLanguageFilterFallback(i.ServiceNames.Where(k => k.TypeId == typesCache.Get <NameType>(NameTypeEnum.Name.ToString())), RequestLanguageId)?.Name ?? "N/A", o => o.Name)
                   .AddSimple(i => i.PublishingStatusId, o => o.PublishingStatusId)
                   .AddSimple(i => i.UnificRootId, o => o.UnificRootId)
                   .AddCollection(i => i.UnificRoot.ServiceServiceChannels.Where(x => VersioningManager.ApplyPublishingStatusFilterFallback(x.ServiceChannel.Versions) != null), o => o.ChannelRelations)
                   .AddCollection <ILanguageAvailability, VmLanguageAvailabilityInfo>(i => langAvailabilities.OrderBy(x => x.Language.OrderNumber), o => o.LanguagesAvailabilities)
                   .GetFinal());
        }
Esempio n. 8
0
 public override VmChannelListItem TranslateEntityToVm(ServiceServiceChannel entity)
 {
     return(CreateEntityViewModelDefinition <VmChannelListItem>(entity)
            .AddNavigation(input => VersioningManager.ApplyPublishingStatusFilterFallback(input.ServiceChannel.Versions), output => output)
            .GetFinal());
 }