public override VmChannelListItem TranslateEntityToVm(ServiceChannelVersioned entity) { var definition = CreateEntityViewModelDefinition <VmChannelListItem>(entity) .AddNavigation(i => VersioningManager.ApplyLanguageFilterFallback(i.ServiceChannelNames.Where(k => k.TypeId == typesCache.Get <NameType>(NameTypeEnum.Name.ToString())), RequestLanguageId)?.Name ?? "N/A", o => o.Name) //.AddPartial(i => i.Type, o => o as IVmEntityType) .AddSimple(i => EntityTypeEnum.Channel, o => o.MainEntityType) .AddNavigation(i => typesCache.GetByValue <ServiceChannelType>(i.TypeId), o => o.SubEntityType) .AddSimple(i => i.TypeId, o => o.TypeId) .AddSimple(i => i.UnificRootId, o => o.UnificRootId) .AddSimple(i => i.PublishingStatusId, o => o.PublishingStatusId) .AddLocalizable(i => i.Phones.Select(x => x.Phone), o => o.PhoneNumber) .AddLocalizable(i => i.PrintableFormChannels?.FirstOrDefault()?.FormIdentifiers, o => o.FormIdentifier) .AddSimple(i => i.Modified, o => o.Modified) .AddSimple(i => i.Id, o => o.Id) .AddSimple(i => i.UnificRootId, o => o.RootId) .AddCollection <ILanguageAvailability, VmLanguageAvailabilityInfo>(i => i.LanguageAvailabilities.OrderBy(x => languageOrderCache.Get(x.LanguageId)), o => o.LanguagesAvailabilities) .AddNavigation(i => i.Versioning, o => o.Version) .AddSimple(i => i.OrganizationId, o => o.OrganizationId); if (entity.UnificRoot != null) { definition.AddSimple(i => i.UnificRoot.ServiceServiceChannels.Count( x => x.Service.Versions.Any(y => y.PublishingStatusId != typesCache.Get <PublishingStatusType>(PublishingStatus.Deleted.ToString()))), o => o.ConnectedServices); } var phone = definition.GetFinal(); if (phone.PhoneNumber == null) { definition.AddNavigation(i => i.Phones.Select(x => x.Phone).FirstOrDefault(), o => o.PhoneNumber); } return(phone); }
public override VmConnectedChannel TranslateEntityToVm(ServiceChannelVersioned entity) { return(CreateEntityViewModelDefinition <VmConnectedChannel>(entity) .AddSimple(i => i.Id, o => o.Id) .AddSimple(i => i.UnificRootId, o => o.RootId) .AddNavigation(i => VersioningManager.ApplyLanguageFilterFallback(i.ServiceChannelNames.Where(k => k.TypeId == typesCache.Get <NameType>(NameTypeEnum.Name.ToString())), RequestLanguageId)?.Name ?? "N/A", o => o.Name) .AddNavigation(i => i.Type as TypeBase, o => o.Type) .AddSimple(i => i.TypeId, o => o.TypeId) .AddSimple(i => i.PublishingStatusId, o => o.PublishingStatusId) .AddCollection <ILanguageAvailability, VmLanguageAvailabilityInfo>(i => i.LanguageAvailabilities.OrderBy(x => x.Language.OrderNumber), o => o.LanguagesAvailabilities) .GetFinal()); }
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()); }
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); }