Beispiel #1
0
 private void SetStep3Translation(ITranslationDefinitions <VmService, ServiceVersioned> definition)
 {
     definition.AddCollectionWithRemove(i =>
     {
         var number = 1;
         i.Step3Form.ServiceProducers.ForEach(p => p.Order = number++);
         return(i.Step3Form.ServiceProducers);
     }, o => o.ServiceProducers, r => true);
 }
Beispiel #2
0
//
//        public ITranslationDefinitions<TIn, ServiceChannelVersioned> AddWebPagesDefinition<TIn>(ITranslationDefinitions<TIn, ServiceChannelVersioned> definition, IWebPages model, Guid? referenceId) where TIn : IWebPages
//        {
//            model.WebPages?.ForEach(i => i.OwnerReferenceId = referenceId);
//            return definition.AddCollection(i => i.WebPages, o => o.WebPages, true);
//        }
//
//        public ITranslationDefinitions<ServiceChannelVersioned, TOut> AddWebPagesDefinition<TOut>(ITranslationDefinitions<ServiceChannelVersioned, TOut> definition, LanguageCode languageCode) where TOut : IWebPages
//        {
//            return definition.AddCollection(i => i.WebPages.Where(x => languageCache.Get(languageCode.ToString()) == x.WebPage.LocalizationId), o => o.WebPages);
//        }
//
        public ServiceChannelTranslationDefinitionHelper AddAttachmentsDefinition <TIn>(ITranslationDefinitions <TIn, ServiceChannelVersioned> definition, IAttachments model, Guid?referenceId) where TIn : IAttachments
        {
            definition
            .AddCollectionWithRemove(input => input.Attachments.SelectMany(pair =>
            {
                var localizationId = languageCache.Get(pair.Key);
                var orderNumber    = 0;
                return(pair.Value.Select(at =>
                {
                    at.OwnerReferenceId = referenceId;
                    at.LocalizationId = localizationId;
                    at.OrderNumber = orderNumber++;
                    return at;
                }));
            }), output => output.Attachments, x => true);
            return(this);
        }
 protected override void TranslateDescription(ITranslationDefinitions <VmServiceViewsJsonItem, ServiceClass> definition, Guid?id)
 {
     definition.AddCollectionWithRemove(i => i.Notes?.Select(x => GetLanguageText(string.Join(" ", x.Value), x.Key, id)) ?? new List <JsonLanguageLabel>(), o => o.Descriptions, x => true);
 }
Beispiel #4
0
        private void SetStep1Translation(ITranslationDefinitions <VmService, ServiceVersioned> definition, VmService service)
        {
            var model = service.Step1Form;
            var order = 1;

            model.Laws?.ForEach(i =>
            {
                i.OrderNumber      = order++;
                i.OwnerReferenceId = model.Id;
            });

            var serviceTypeId = model.GeneralDescription?.UnificRootId == null ? model.ServiceTypeId : model.GeneralDescription.TypeId;

            var names = new List <VmName>()
            {
                new VmName {
                    Name = model.ServiceName, TypeId = typesCache.Get <NameType>(NameTypeEnum.Name.ToString()), OwnerReferenceId = service.Id
                }
            };

            if (!string.IsNullOrEmpty(model.AlternateServiceName))
            {
                names.Add(new VmName {
                    Name = model.AlternateServiceName, TypeId = typesCache.Get <NameType>(NameTypeEnum.AlternateName.ToString()), OwnerReferenceId = service.Id
                });
            }

            var descriptions = new List <VmDescription>()
            {
                new VmDescription {
                    Description = model.ShortDescriptions, TypeId = typesCache.Get <DescriptionType>(DescriptionTypeEnum.ShortDescription.ToString()), OwnerReferenceId = service.Id
                },
                new VmDescription {
                    Description = model.Description, TypeId = typesCache.Get <DescriptionType>(DescriptionTypeEnum.Description.ToString()), OwnerReferenceId = service.Id
                },
                new VmDescription {
                    Description = model.UserInstruction, TypeId = typesCache.Get <DescriptionType>(DescriptionTypeEnum.ServiceUserInstruction.ToString()), OwnerReferenceId = service.Id
                },
                new VmDescription {
                    Description = model.AdditionalInformation, TypeId = typesCache.Get <DescriptionType>(DescriptionTypeEnum.ChargeTypeAdditionalInfo.ToString()), OwnerReferenceId = service.Id
                }
            };

            if (!typesCache.Compare <ServiceType>(serviceTypeId, ServiceTypeEnum.Service.ToString()))
            {
                descriptions.Add(new VmDescription {
                    Description = model.AdditionalInformationDeadLine, TypeId = typesCache.Get <DescriptionType>(DescriptionTypeEnum.DeadLineAdditionalInfo.ToString()), OwnerReferenceId = service.Id
                });
                descriptions.Add(new VmDescription {
                    Description = model.AdditionalInformationProcessingTime, TypeId = typesCache.Get <DescriptionType>(DescriptionTypeEnum.ProcessingTimeAdditionalInfo.ToString()), OwnerReferenceId = service.Id
                });
                //    descriptions.Add(new VmDescription { Description = model.AdditionalInformationTasks, TypeId = typesCache.Get<DescriptionType>(DescriptionTypeEnum.TasksAdditionalInfo.ToString()), OwnerReferenceId = service.Id });
                descriptions.Add(new VmDescription {
                    Description = model.AdditionalInformationValidityTime, TypeId = typesCache.Get <DescriptionType>(DescriptionTypeEnum.ValidityTimeAdditionalInfo.ToString()), OwnerReferenceId = service.Id
                });
            }
            else
            {
                if (service.Id.IsAssigned())
                {
                    descriptions.Add(new VmDescription {
                        TypeId = typesCache.Get <DescriptionType>(DescriptionTypeEnum.DeadLineAdditionalInfo.ToString()), OwnerReferenceId = service.Id
                    });
                    descriptions.Add(new VmDescription {
                        TypeId = typesCache.Get <DescriptionType>(DescriptionTypeEnum.ProcessingTimeAdditionalInfo.ToString()), OwnerReferenceId = service.Id
                    });
                    //descriptions.Add(new VmDescription { TypeId = typesCache.Get<DescriptionType>(DescriptionTypeEnum.TasksAdditionalInfo.ToString()), OwnerReferenceId = service.Id });
                    descriptions.Add(new VmDescription {
                        TypeId = typesCache.Get <DescriptionType>(DescriptionTypeEnum.ValidityTimeAdditionalInfo.ToString()), OwnerReferenceId = service.Id
                    });
                }
            }

            if (typesCache.Compare <AreaInformationType>(service.Step1Form.AreaInformationTypeId, AreaInformationTypeEnum.AreaType.ToString()))
            {
                var areas = service.Step1Form.BusinessRegions.Union(service.Step1Form.HospitalRegions).Union(service.Step1Form.Provinces);
                definition.AddCollectionWithRemove(i => areas.Select(x => new VmListItem {
                    Id = x, OwnerReferenceId = service.Id
                }), o => o.Areas, r => true);
                definition.AddCollectionWithRemove(i => i.Step1Form.Municipalities.Select(x => new VmListItem {
                    Id = x, OwnerReferenceId = service.Id
                }), o => o.AreaMunicipalities, r => true);
            }
            else
            {   //Remove Areas
                definition.AddCollectionWithRemove(i => new List <VmListItem>()
                {
                }, o => o.Areas, r => true);
                definition.AddCollectionWithRemove(i => new List <VmListItem>()
                {
                }, o => o.AreaMunicipalities, r => true);
            }

            var defaultAreaInformationTypeId             = typesCache.Get <AreaInformationType>(AreaInformationTypeEnum.WholeCountry.ToString());
            var generalDescriptionUnificRootIdIsAssigned = model.GeneralDescription != null?model.GeneralDescription.UnificRootId.IsAssigned() : false;

            var languageCount = 0;

            definition
            .AddSimple(i => generalDescriptionUnificRootIdIsAssigned ? model.GeneralDescription.UnificRootId : (Guid?)null, o => o.StatutoryServiceGeneralDescriptionId)
            .AddSimple(i => generalDescriptionUnificRootIdIsAssigned ? null : i.Step1Form.ServiceTypeId, o => o.TypeId)
            .AddSimple(i => i.Step1Form.ChargeType, o => o.ChargeTypeId)
            .AddSimple(i => i.Step1Form.AreaInformationTypeId.IsAssigned() ? i.Step1Form.AreaInformationTypeId : defaultAreaInformationTypeId, output => output.AreaInformationTypeId)
            .AddCollectionWithKeep(i => names, o => o.ServiceNames, TranslationPolicy.FetchData, x => x.LocalizationId != RequestLanguageId)
            .AddCollection(i => descriptions, o => o.ServiceDescriptions)
            .AddCollection(
                i => new List <VmServiceRequirement> {
                new VmServiceRequirement {
                    Requirement = model.ServiceUsage, Id = service.Id
                }
            },
                o => o.ServiceRequirements)
            .AddCollectionWithRemove(i => i.Step1Form.Languages.Select(x => new VmListItem {
                Id = x, OrderNumber = languageCount++, OwnerReferenceId = i.Id
            }), o => o.ServiceLanguages, r => true)
            //.AddCollection(i => i.Step1Form.Laws.Where(x => !string.IsNullOrEmpty(x.UrlAddress.TryGet(RequestLanguageCode.ToString()))), output => output.ServiceLaws, false)
            .AddCollectionWithKeep(i => i.Step1Form.Laws /*.Where(x => !string.IsNullOrEmpty(x.UrlAddress.TryGet(RequestLanguageCode.ToString())))*/, output => output.ServiceLaws, c =>
            {
                c.Check(h => h.Law).Check(h => h.Names).Any();
                c.Check(h => h.Law).Check(h => h.WebPages).Any();
                c.Check(h => h.Law).Check(h => h.WebPages).Check(h => h.WebPage).Check(h => h.LocalizationId).Not(RequestLanguageId);
            })
            .AddCollectionWithRemove(i => i.Step1Form.Organizers.Select(x => new VmTreeItem {
                Id = x, OwnerReferenceId = i.Id
            }), o => o.OrganizationServices, r => true)
            .AddSimple(i => i.Step1Form.FundingTypeId, o => o.FundingTypeId)
            .AddSimple(i => i.Step1Form.OrganizationId, o => o.OrganizationId)
            .AddCollectionWithKeep(i => i.Step1Form.ServiceVouchers, o => o.ServiceWebPages, c => c.Check(h => h.WebPage).Check(h => h.LocalizationId).Not(RequestLanguageId));

            // handle selfProduced serviceProducers
            if (service.Id.IsAssigned())
            {
                var selfProducedId            = typesCache.Get <ProvisionType>(ProvisionTypeEnum.SelfProduced.ToString());
                var selfProducedOrganizations = service.Step1Form.ServiceProducers.Where(p => p.ProvisionType == selfProducedId && p.SelfProducers != null).Select(x =>
                {
                    var organizers = service.Step1Form.Organizers;
                    if (service.Step1Form.OrganizationId.IsAssigned())
                    {
                        organizers.Add(service.Step1Form.OrganizationId);
                    }

                    x.SelfProducers = x.SelfProducers.Where(org => organizers.Contains(org)).ToList();
                    return(x);
                }).ToList();
                definition.AddCollectionWithKeep(i => selfProducedOrganizations, o => o.ServiceProducers, r => r.ProvisionTypeId != selfProducedId);
            }
        }