示例#1
0
        public override ServiceChannelWebPage TranslateVmToEntity(VmOpenApiWebPageWithOrderNumber vModel)
        {
            var typeId = typesCache.Get <WebPageType>(WebPageTypeEnum.HomePage.ToString());

            var definition = CreateViewModelEntityDefinition <ServiceChannelWebPage>(vModel)
                             .DisableAutoTranslation();

            if (vModel.ExistsOnePerLanguage)
            {
                definition.UseDataContextUpdate(i => i.OwnerReferenceId.HasValue, i => o => i.OwnerReferenceId == o.ServiceChannelVersionedId &&
                                                typeId == o.TypeId && languageCache.Get(i.Language) == o.WebPage.LocalizationId, w => w.UseDataContextCreate(x => true));
            }
            else
            {
                definition.UseDataContextUpdate(i => i.OwnerReferenceId.HasValue, i => o => i.OwnerReferenceId == o.ServiceChannelVersionedId &&
                                                typeId == o.TypeId && languageCache.Get(i.Language) == o.WebPage.LocalizationId && i.Url == o.WebPage.Url, w => w.UseDataContextCreate(x => true));
            }

            if (vModel.OwnerReferenceId.HasValue)
            {
                var entity = definition.GetFinal();
                if (entity.WebPageId != null && entity.Created != DateTime.MinValue)
                {
                    // We are updating already existing item
                    vModel.Id = entity.WebPageId;
                }
            }

            definition.AddNavigation(i => i, o => o.WebPage)
            .AddSimple(i => typeId, o => o.TypeId);

            return(definition.GetFinal());
        }
示例#2
0
        public override Law TranslateVmToEntity(VmLaw vModel)
        {
            bool exists = vModel.Id.IsAssigned();

            var transaltionDefinition = CreateViewModelEntityDefinition <Law>(vModel)
                                        .DefineEntitySubTree(i => i.Include(j => j.Names).Include(j => j.WebPages).ThenInclude(j => j.WebPage))
                                        .UseDataContextCreate(input => !exists, output => output.Id, input => Guid.NewGuid())
                                        .UseDataContextUpdate(input => exists, input => output => input.Id == output.Id)
                                        .AddCollection(i => i.UrlAddress?.Select(
                                                           pair => new VmWebPage()
            {
                OwnerReferenceId = i.Id, UrlAddress = pair.Value, LocalizationId = languageCache.Get(pair.Key)
            }), o => o.WebPages, true)
                                        .AddCollection(i => i.Name?.Select(
                                                           pair => new VmName()
            {
                OwnerReferenceId = i.Id, Name = pair.Value, LocalizationId = languageCache.Get(pair.Key)
            }), o => o.Names, true)
                                        .AddSimple(i => i.OrderNumber, o => o.OrderNumber)
            ;

            var entity = transaltionDefinition.GetFinal();

            return(entity);
        }
        public override ServiceChannelPhone TranslateVmToEntity(V4VmOpenApiPhoneWithType vModel)
        {
            var exists = vModel.OwnerReferenceId.IsAssigned();

            var definition = CreateViewModelEntityDefinition(vModel);

            if (vModel.ExistsOnePerLanguage)
            {
                definition.UseDataContextCreate(i => !exists)
                .UseDataContextUpdate(i => exists, i => o => i.OwnerReferenceId == o.ServiceChannelVersionedId &&
                                      languageCache.Get(i.Language) == o.Phone.LocalizationId, e => e.UseDataContextCreate(x => true));
            }
            else
            {
                Guid typeId = typesCache.Get <PhoneNumberType>(vModel.Type);
                definition.UseDataContextCreate(i => !exists)
                .UseDataContextUpdate(i => exists, i => o => i.OwnerReferenceId == o.ServiceChannelVersionedId && typeId == o.Phone.TypeId &&
                                      languageCache.Get(i.Language) == o.Phone.LocalizationId && i.Number == o.Phone.Number && i.PrefixNumber == o.Phone.PrefixNumber.Code,
                                      e => e.UseDataContextCreate(x => true));
            }

            if (exists)
            {
                var entity = definition.GetFinal();
                if (entity.Created != DateTime.MinValue)
                {
                    vModel.Id = entity.PhoneId;
                }
            }

            definition.AddNavigation(i => i, o => o.Phone);

            return(definition.GetFinal());
        }
示例#4
0
 public override ServiceDescription TranslateVmToEntity(VmOpenApiLocalizedListItem vModel)
 {
     return(CreateViewModelEntityDefinition <ServiceDescription>(vModel)
            .UseDataContextUpdate(i => i.OwnerReferenceId.HasValue, i => o => o.Type.Code == i.Type &&
                                  o.LocalizationId == languageCache.Get(i.Language) && i.OwnerReferenceId == o.ServiceVersionedId, name => name.UseDataContextCreate(x => true))
            .AddNavigation(i => IsTextEditorField(typesCache.Get <DescriptionType>(vModel.Type)) ? textManager.ConvertMarkdownToJson(i.Value) : i.Value, o => o.Description)
            .AddSimple(i => languageCache.Get(i.Language), o => o.LocalizationId)
            .AddSimple(i => typesCache.Get <DescriptionType>(i.Type), o => o.TypeId)
            .GetFinal());
 }
 private VmName CreateName(string language, string value, VmChannelBase vModel, NameTypeEnum typeEnum)
 {
     return(new VmName
     {
         Name = value,
         TypeId = typesCache.Get <NameType>(typeEnum.ToString()),
         OwnerReferenceId = vModel.Id,
         LocalizationId = languageCache.Get(language)
     });
 }
        public override PrintableFormChannel TranslateVmToEntity(VmPrintableFormInput vModel)
        {
            vModel.DeliveryAddress.SafeCall(i =>
            {
                i.OwnerReferenceId = vModel.Id;
                i.PostalCode       = i.PostalCode == null
                    ? new VmPostalCode()
                {
                    Code = "Undefined"
                }
                    : i.PostalCode;
            });
            var transaltionDefinition = CreateViewModelEntityDefinition <PrintableFormChannel>(vModel)
                                        .UseDataContextCreate(i => !i.Id.IsAssigned(), o => o.Id, i => Guid.NewGuid())
                                        .UseDataContextLocalizedUpdate(i => i.Id.IsAssigned(), i => o => o.ServiceChannelVersionedId == i.Id)
                                        .Propagation((i, o) => i.PrintableFormChannelId = o.Id)
                                        .AddCollection(i => i.FormIdentifier?.Select(
                                                           pair => new VmPrintableFormChannelIdentifier()
            {
                PrintableFormChannelId = i.PrintableFormChannelId,
                FormIdentifier         = pair.Value,
                LocalizationId         = languageCache.Get(pair.Key)
            }),
                                                       o => o.FormIdentifiers, true)
                                        .AddCollection(i => i.FormReceiver?.Select(
                                                           pair => new VmPrintableFormChannelReceiver()
            {
                PrintableFormChannelId = i.PrintableFormChannelId,
                FormReceiver           = pair.Value,
                LocalizationId         = languageCache.Get(pair.Key)
            }),
                                                       o => o.FormReceivers, true)
                                        .AddCollectionWithRemove(i => i.FormFiles?.SelectMany(pair =>
            {
                var orderNumber    = 0;
                var localizationId = languageCache.Get(pair.Key);
                return(pair.Value.Select(ff =>
                {
                    ff.OrderNumber = orderNumber++;
                    ff.OwnerReferenceId = i.PrintableFormChannelId;
                    ff.LocalizationId = localizationId;
                    return ff;
                }));
            }), o => o.ChannelUrls, x => true)
                                        .AddNavigation(i => (i.DeliveryAddress?.PostalCode != null) ? i.DeliveryAddress : null, o => o.DeliveryAddress);

            if (vModel.DeliveryAddress?.PostalCode == null)
            {
                transaltionDefinition.AddSimple(i => (Guid?)null, o => o.DeliveryAddressId);
            }
            var entity = transaltionDefinition.GetFinal();

            return(entity);
        }
示例#7
0
 public override ServiceCollectionDescription TranslateVmToEntity(VmOpenApiLanguageItem vModel)
 {
     return(CreateViewModelEntityDefinition <ServiceCollectionDescription>(vModel)
            .UseDataContextUpdate(i => i.OwnerReferenceId.HasValue,
                                  i => o => o.LocalizationId == languageCache.Get(i.Language) && i.OwnerReferenceId == o.ServiceCollectionVersionedId,
                                  name => name.UseDataContextCreate(x => true))
            .AddNavigation(i => textManager.ConvertMarkdownToJson(i.Value), o => o.Description)
            .AddSimple(i => languageCache.Get(i.Language), o => o.LocalizationId)
            .AddSimple(i => typesCache.Get <DescriptionType>(DescriptionTypeEnum.Description.ToString()), o => o.TypeId)
            .GetFinal());
 }
示例#8
0
        private IList <VmName> GetNames(ImportStatutoryServiceGeneralDescription model, StatutoryServiceGeneralDescriptionVersioned generalDescriptionVersioned)
        {
            var nameType = typesCache.Get <NameType>(NameTypeEnum.Name.ToString());

            return(model.Name.Select(x => new VmName
            {
                Name = x.Label,
                TypeId = nameType,
                OwnerReferenceId = generalDescriptionVersioned.Id,
                LocalizationId = languageCache.Get(x.Lang)
            }).ToList());
        }
示例#9
0
        public VmKeywordSearchOutput KeywordSearch(VmKeywordSearch model, IUnitOfWork unitOfWork)
        {
            var localizationId = languageCache.Get(model.LocalizationCode);
            var keywordRep     = unitOfWork.CreateRepository <IKeywordRepository>();
            var name           = model.Name.ToLower();
            var keywords       = keywordRep.All().Where(i => i.Name.ToLower().Contains(name) && i.LocalizationId == localizationId).OrderBy(i => i.Name).Take(CoreConstants.MaximumNumberOfAllItems + 1).ToList();

            return(new VmKeywordSearchOutput()
            {
                Keywords = TranslationManagerToVm.TranslateAll <Keyword, VmKeywordItem>(keywords.Take(CoreConstants.MaximumNumberOfAllItems)), MoreAvailable = keywords.Count > CoreConstants.MaximumNumberOfAllItems
            });
        }
示例#10
0
        protected ITranslationDefinitions <TModel, Phone> CreateVmEntityBaseDefinitions(TModel vModel)
        {
            var exists = vModel.Id.IsAssigned();

            var serviceChargeType = (string.IsNullOrEmpty(vModel.ServiceChargeType))
                ? typesCache.Get <ServiceChargeType>(ServiceChargeTypeEnum.Charged.ToString())
                : typesCache.Get <ServiceChargeType>(vModel.ServiceChargeType);

            var definitions = CreateViewModelEntityDefinition(vModel)
                              .UseDataContextCreate(i => !exists, o => o.Id, i => Guid.NewGuid())
                              .UseDataContextUpdate(i => exists, i => o => i.Id == o.Id, e => e.UseDataContextCreate(x => true))
                              .AddNavigation(i => i.Number, o => o.Number)
                              .AddNavigation(i => i.AdditionalInformation, o => o.AdditionalInformation)
                              .AddNavigation(i => i.ChargeDescription, o => o.ChargeDescription)
                              .AddSimple(i => serviceChargeType, o => o.ChargeTypeId)
                              .AddSimple(i => languageCache.Get(i.Language), o => o.LocalizationId)
                              .AddSimple(i => i.OrderNumber, o => o.OrderNumber);

            // IsFinnishServiceNumber is the determinant. See Jira bug https://jira.csc.fi/browse/PTV-1476
            if (!vModel.IsFinnishServiceNumber)
            {
                definitions.AddNavigation(i => i.PrefixNumber, o => o.PrefixNumber);
            }

            return(definitions);
        }
示例#11
0
        public override ServiceChannelEmail TranslateVmToEntity(VmEmailData vModel)
        {
            if (vModel == null)
            {
                return(null);
            }
            bool existsById             = vModel.Id.IsAssigned();
            var  existsByOwnerReference = !vModel.Id.IsAssigned() && vModel.OwnerReferenceId.IsAssigned();
            Guid languageId             = vModel.LanguageId.IsAssigned()
                ? vModel.LanguageId.Value
                : languageCache.Get(RequestLanguageCode.ToString());

            var translation = CreateViewModelEntityDefinition(vModel)
                              .UseDataContextCreate(input => !existsById && !existsByOwnerReference)
                              .UseDataContextUpdate(input => existsById || existsByOwnerReference, input => output =>
                                                    (!input.Id.IsAssigned() || input.Id == output.EmailId) &&
                                                    (!input.OwnerReferenceId.IsAssigned() || output.ServiceChannelVersionedId == input.OwnerReferenceId) &&
                                                    (languageId == output.Email.LocalizationId),
                                                    create => create.UseDataContextCreate(c => true)
                                                    );

            if (existsByOwnerReference)
            {
                var serviceChannelEmail = translation.GetFinal();
                if (serviceChannelEmail.Created > DateTime.MinValue)
                {
                    vModel.Id = serviceChannelEmail.EmailId;
                }
            }

            return(translation
                   .AddNavigation(input => input, output => output.Email)
                   .GetFinal());
        }
        public override ServiceChannelVersioned TranslateVmToEntity(VmServiceLocationChannel vModel)
        {
            MergeFaxNumbers(vModel);

            var definition = CreateViewModelEntityDefinition(vModel)
                             .DisableAutoTranslation()
                             .UseDataContextCreate(i => !i.Id.IsAssigned(), o => o.Id, i => Guid.NewGuid())
                             .UseDataContextUpdate(i => i.Id.IsAssigned(), i => o => o.Id == i.Id)
                             .UseVersioning <ServiceChannelVersioned, ServiceChannel>(o => o)
                             .AddLanguageAvailability(i => i, o => o)
                             .AddNavigation(i => ServiceChannelTypeEnum.ServiceLocation.ToString(), o => o.Type)
                             .AddNavigationOneMany(i => i, o => o.ServiceLocationChannels)
                             .AddCollectionWithRemove(i => i.WebPages.SelectMany(pair =>
            {
                var localizationId = languageCache.Get(pair.Key);
                var orderNumber    = 0;
                return(pair.Value.Select(sv =>
                {
                    sv.OwnerReferenceId = i.Id;
                    sv.LocalizationId = localizationId;
                    sv.OrderNumber = orderNumber++;
                    return sv;
                }));
            }), o => o.WebPages, x => true)
            ;

            definitionHelper
            .AddLanguagesDefinition(definition)
            .AddChannelBaseDefinition(definition)
            .AddOpeningHoursDefinition(definition);
            return(definition.GetFinal());
        }
        public override ServiceLaw TranslateVmToEntity(V4VmOpenApiLaw vModel)
        {
            var webPage = vModel.WebPages.Where(w => w.Language == LanguageCode.fi.ToString()).FirstOrDefault();
            if (webPage == null)
            {
                webPage = vModel.WebPages.FirstOrDefault();
            }

            var exists = vModel.OwnerReferenceId.IsAssigned();
            if (webPage == null)
            {
                exists = false;
            }

            var language = webPage?.Language;
            var langId = languageCache.Get(language);

            var definition = CreateViewModelEntityDefinition<ServiceLaw>(vModel)
                .UseDataContextUpdate(i => exists,
                i => o => i.OwnerReferenceId == o.ServiceVersionedId && o.Law.WebPages.Where(w => w.WebPage.LocalizationId == langId && w.WebPage.Url == webPage.Url).FirstOrDefault() != null,
                x => x.UseDataContextCreate(i => true));

            if (exists)
            {
                var entity = definition.GetFinal();
                if (entity.Created != DateTime.MinValue) // We are updating existing law
                {
                    vModel.Id = entity.LawId;
                }
            }

            return definition.AddNavigation(i => i, o => o.Law)
                .GetFinal();
        }
示例#14
0
        public override ServiceChannelPhone TranslateVmToEntity(VmPhone vModel)
        {
            if (vModel == null)
            {
                return(null);
            }

            bool exists             = vModel.Id.IsAssigned();
            bool updateWithLanguage = vModel.OwnerReferenceId.IsAssigned() && vModel.LanguageId.IsAssigned();
            Guid?languageId         = vModel.LanguageId ?? languageCache.Get(RequestLanguageCode.ToString());
            var  translation        = CreateViewModelEntityDefinition(vModel)
                                      .UseDataContextCreate(input => !exists && !updateWithLanguage)
                                      .UseDataContextUpdate(input => exists || updateWithLanguage,
                                                            input => output =>
                                                            (!input.Id.IsAssigned() || input.Id == output.PhoneId) &&
                                                            (languageId == output.Phone.LocalizationId) &&
                                                            (!input.OwnerReferenceId.IsAssigned() || output.ServiceChannelVersionedId == vModel.OwnerReferenceId),
                                                            e => e.UseDataContextCreate(x => true));

            if (!exists && updateWithLanguage)
            {
                var serviceChannelPhone = translation.GetFinal();
                if (serviceChannelPhone.Created > DateTime.MinValue)
                {
                    vModel.Id = serviceChannelPhone.PhoneId;
                }
            }

            return(translation
                   .AddNavigation(input => input, output => output.Phone)
                   .GetFinal());
        }
        public override StatutoryServiceGeneralDescriptionVersioned TranslateVmToEntity(VmGeneralDescriptionBase vModel)
        {
            var names = new List <VmName>();

            names.AddNullRange(vModel.Name?.Select(pair => CreateName(pair.Key, pair.Value, vModel, NameTypeEnum.Name)));
            var serviceTypeService = typesCache.Get <ServiceType>(ServiceTypeEnum.Service.ToString());
            var descriptions       = new List <VmDescription>();

            descriptions.AddNullRange(vModel.ShortDescription?.Select(pair => CreateDescription(pair.Key, pair.Value, vModel, DescriptionTypeEnum.ShortDescription)));
            descriptions.AddNullRange(vModel.Description?.Select(pair => CreateDescription(pair.Key, pair.Value, vModel, DescriptionTypeEnum.Description)));
            descriptions.AddNullRange(vModel.BackgroundDescription?.Select(pair => CreateDescription(pair.Key, pair.Value, vModel, DescriptionTypeEnum.BackgroundDescription)));
            descriptions.AddNullRange(vModel.DeadLineInformation?.Select(pair => CreateDescription(pair.Key, pair.Value, vModel, DescriptionTypeEnum.DeadLineAdditionalInfo, serviceTypeService == vModel.ServiceType)));
            descriptions.AddNullRange(vModel.ProcessingTimeInformation?.Select(pair => CreateDescription(pair.Key, pair.Value, vModel, DescriptionTypeEnum.ProcessingTimeAdditionalInfo, serviceTypeService == vModel.ServiceType)));
            descriptions.AddNullRange(vModel.ValidityTimeInformation?.Select(pair => CreateDescription(pair.Key, pair.Value, vModel, DescriptionTypeEnum.ValidityTimeAdditionalInfo, serviceTypeService == vModel.ServiceType)));
            descriptions.AddNullRange(vModel.UserInstruction?.Select(pair => CreateDescription(pair.Key, pair.Value, vModel, DescriptionTypeEnum.ServiceUserInstruction)));
            descriptions.AddNullRange(vModel.ChargeType?.AdditionalInformation?.Select(pair => CreateDescription(pair.Key, pair.Value, vModel, DescriptionTypeEnum.ChargeTypeAdditionalInfo)));

            var definition = CreateViewModelEntityDefinition(vModel)
                             .DisableAutoTranslation()
                             .AddSimple(i => i?.ChargeType.ChargeType, o => o.ChargeTypeId)
                             .AddSimple(i => i.ServiceType.HasValue ? i.ServiceType.Value : throw new PtvArgumentException("Service type has to be provided"), o => o.TypeId)
                             .AddLanguageAvailability(i => i, o => o)
                             .AddCollection(i => names, o => o.Names, true)
                             .AddCollection(i => descriptions, o => o.Descriptions, true)
                             .AddCollection(i => i.ConditionOfServiceUsage?.Select(
                                                pair => new VmServiceRequirement()
            {
                Id = i.Id, Requirement = pair.Value, LocalizationId = languageCache.Get(pair.Key)
            }), o => o.StatutoryServiceRequirements, true)
                             .AddCollectionWithKeep(i => (i.Laws?.Where(x => !string.IsNullOrEmpty(x.UrlAddress.TryGet(RequestLanguageCode.ToString()))) ?? new List <VmLaw>()).Select(
                                                        l =>
            {
                l.OwnerReferenceId = i.Id;
                return(l);
            }), output => output.StatutoryServiceLaws, 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.TargetGroups?.Select(x => new VmTargetGroupListItem {
                Id = x, OwnerReferenceId = i.Id
            }) ?? new List <VmTargetGroupListItem>()), o => o.TargetGroups, x => true);

            return(definition.GetFinal());
        }
示例#16
0
        public override ServiceVersioned TranslateVmToEntity(VmServiceInput vModel)
        {
            var definition = CreateViewModelEntityDefinition(vModel)
                             .DefineEntitySubTree(i => i.Include(j => j.ServiceLaws).ThenInclude(j => j.Law).ThenInclude(j => j.WebPages).ThenInclude(j => j.WebPage))
                             .DefineEntitySubTree(i => i.Include(j => j.ServiceLaws).ThenInclude(j => j.Law).ThenInclude(j => j.Names))
                             .DefineEntitySubTree(i => i.Include(j => j.ServiceWebPages).ThenInclude(j => j.WebPage))
                             .UseDataContextCreate(i => !i.Id.IsAssigned(), o => o.Id, i => Guid.NewGuid())
                             .UseDataContextUpdate(i => i.Id.IsAssigned(), i => o => o.Id == i.Id)
                             .UseVersioning <ServiceVersioned, Service>(o => o)
                             .AddPartial(i => i as VmServiceBase)
                             .AddSimple(i => i.GeneralDescriptionServiceTypeId.HasValue ? null : i.ServiceType, o => o.TypeId)
                             .AddSimple(i => i.GeneralDescriptionChargeTypeId.HasValue ? null : i.ChargeType?.ChargeType, o => o.ChargeTypeId)
                             .AddCollectionWithRemove(i => i.ServiceClasses?.Select(x => new VmListItem()
            {
                Id = x, OwnerReferenceId = i.Id
            }), o => o.ServiceServiceClasses, x => true)
                             .AddCollectionWithRemove(i => i.OntologyTerms?.Select(x => new VmListItem()
            {
                Id = x, OwnerReferenceId = i.Id
            }), o => o.ServiceOntologyTerms, x => true)
                             .AddCollectionWithRemove(i => i.LifeEvents?.Select(x => new VmListItem()
            {
                Id = x, OwnerReferenceId = i.Id
            }), o => o.ServiceLifeEvents, x => true)
                             .AddCollectionWithRemove(i => i.IndustrialClasses?.Select(x => new VmListItem()
            {
                Id = x, OwnerReferenceId = i.Id
            }), o => o.ServiceIndustrialClasses, x => true)
                             .AddCollectionWithRemove(i =>
            {
                var existingOnes = i.Keywords.SelectMany(pair =>
                {
                    return(pair.Value.Select(kw =>
                                             new VmKeywordItem()
                    {
                        Id = kw, OwnerReferenceId = i.Id
                    }));
                });

                var newKeywords = i.NewKeywords?.SelectMany(pair =>
                {
                    var localizationId = languageCache.Get(pair.Key);
                    return(pair.Value?.Select(
                               x => new VmKeywordItem()
                    {
                        Name = x, OwnerReferenceId = i.Id, LocalizationId = localizationId
                    }) ??
                           new List <VmKeywordItem>());
                });

                return(existingOnes.Concat(newKeywords ?? new List <VmKeywordItem>()));
            }, o => o.ServiceKeywords, x => true /*c => c.Check(h => h.Keyword).Check(h => h.LocalizationId).Not(RequestLanguageId)*/);

            /*.AddCollectionWithRemove(i => i.Keywords?.Select(x => new VmKeywordItem() { Id = x.Id, OwnerReferenceId = i.Id }).Concat(i.NewKeywords?.Select(
             *  x => new VmKeywordItem() {Name = x, OwnerReferenceId = i.Id}) ?? new List<VmKeywordItem>()), o => o.ServiceKeywords, x => true);*/

            return(definition.GetFinal());
        }
示例#17
0
 private VmLanguageText CreateName(string language, string value, VmOpeningHour vModel)
 {
     return(new VmLanguageText
     {
         Text = value,
         Id = vModel.Id,
         LocalizationId = languageCache.Get(language)
     });
 }
示例#18
0
 public override MunicipalityName TranslateVmToEntity(VmJsonName vModel)
 {
     return(CreateViewModelEntityDefinition <MunicipalityName>(vModel)
            .DisableAutoTranslation()
            .UseDataContextCreate(i => !i.OwnerReferenceId.IsAssigned())
            .UseDataContextUpdate(i => i.OwnerReferenceId.IsAssigned(), i => o => (i.OwnerReferenceId == o.MunicipalityId && o.LocalizationId == languageCache.Get(i.Language)), def => def.UseDataContextCreate(i => true))
            .AddNavigation(i => i.Name, o => o.Name)
            .AddSimple(i => languageCache.Get(i.Language), o => o.LocalizationId)
            .GetFinal());
 }
 public override OrganizationName TranslateVmToEntity(VmOpenApiLocalizedListItem vModel)
 {
     return(CreateViewModelEntityDefinition <OrganizationName>(vModel)
            .UseDataContextUpdate(input => input.OwnerReferenceId.HasValue, input => output => output.Type.Code == input.Type &&
                                  output.LocalizationId == languageCache.Get(input.Language) && input.OwnerReferenceId == output.OrganizationVersionedId, name => name.UseDataContextCreate(x => true))
            .AddNavigation(i => i.Value, o => o.Name)
            .AddNavigation(i => i.Language, o => o.Localization)
            .AddSimple(i => typesCache.Get <NameType>(i.Type), o => o.TypeId)
            .GetFinal());
 }
 public override OrganizationDisplayNameType TranslateVmToEntity(VmOpenApiNameTypeByLanguage vModel)
 {
     return(CreateViewModelEntityDefinition <OrganizationDisplayNameType>(vModel)
            .UseDataContextUpdate(input => input.OwnerReferenceId.HasValue,
                                  input => output => output.LocalizationId == languageCache.Get(input.Language) && input.OwnerReferenceId == output.OrganizationVersionedId,
                                  name => name.UseDataContextCreate(x => true))
            .AddNavigation(i => i.Type, o => o.DisplayNameType)
            .AddNavigation(i => i.Language, o => o.Localization)
            .GetFinal());
 }
 public override LawName TranslateVmToEntity(JsonLanguageLabel vModel)
 {
     return(CreateViewModelEntityDefinition(vModel)
            .DisableAutoTranslation()
            .UseDataContextCreate(i => !i.OwnerReferenceId.IsAssigned())
            .UseDataContextUpdate(i => i.OwnerReferenceId.IsAssigned(), i => o => o.LawId == i.OwnerReferenceId && o.LocalizationId == languageCache.Get(i.Lang), def => def.UseDataContextCreate(i => true))
            .AddNavigation(i => i.Label, o => o.Name)
            .AddSimple(i => languageCache.Get(i.Lang), o => o.LocalizationId)
            .GetFinal());
 }
 public override WebpageChannelUrl TranslateVmToEntity(VmOpenApiLanguageItem vModel)
 {
     return(CreateViewModelEntityDefinition <WebpageChannelUrl>(vModel)
            .DisableAutoTranslation()
            .UseDataContextUpdate(i => i.OwnerReferenceId.IsAssigned(), i => o => i.OwnerReferenceId == o.WebpageChannelId &&
                                  languageCache.Get(i.Language) == o.LocalizationId, e => e.UseDataContextCreate(x => true))
            .AddNavigation(i => i.Value, o => o.Url)
            .AddNavigation(i => i.Language, o => o.Localization)
            .GetFinal());
 }
 public override ServiceChannelName TranslateVmToEntity(VmOpenApiLocalizedListItem vModel)
 {
     return(CreateViewModelEntityDefinition <ServiceChannelName>(vModel)
            .UseDataContextCreate(i => !i.OwnerReferenceId.IsAssigned())
            .UseDataContextUpdate(i => i.OwnerReferenceId.IsAssigned(), i => o => i.OwnerReferenceId == o.ServiceChannelVersionedId && i.Type == o.Type.Code &&
                                  languageCache.Get(i.Language) == o.LocalizationId, def => def.UseDataContextCreate(i => true))
            .AddNavigation(i => i.Value, o => o.Name)
            .AddNavigation(i => i.Language, o => o.Localization)
            .AddSimple(i => typesCache.Get <NameType>(i.Type), o => o.TypeId)
            .GetFinal());
 }
示例#24
0
        public override AddressAdditionalInformation TranslateVmToEntity(VmOpenApiLanguageItem vModel)
        {
            var exists = vModel.OwnerReferenceId.IsAssigned();
            var langId = languageCache.Get(vModel.Language);

            return(CreateViewModelEntityDefinition(vModel)
                   .UseDataContextUpdate(i => exists, i => o => i.OwnerReferenceId.Value == o.AddressId && langId == o.LocalizationId, w => w.UseDataContextCreate(x => true))
                   .AddNavigation(i => i.Value, o => o.Text)
                   .AddNavigation(i => i.Language, o => o.Localization)
                   .GetFinal());
        }
        public override ServiceServiceChannelExtraTypeDescription TranslateVmToEntity(VmOpenApiLanguageItem vModel)
        {
            var languageId = languageCache.Get(vModel.Language);

            return(CreateViewModelEntityDefinition <ServiceServiceChannelExtraTypeDescription>(vModel)
                   .UseDataContextUpdate(i => true, i => o => (i.OwnerReferenceId == o.ServiceServiceChannelExtraTypeId) && languageId == o.LocalizationId,
                                         def => def.UseDataContextCreate(i => true))
                   .AddNavigation(i => i.Value, o => o.Description)
                   .AddSimple(i => languageId, o => o.LocalizationId)
                   .GetFinal());
        }
示例#26
0
        public override Keyword TranslateVmToEntity(VmOpenApiLanguageItem vModel)
        {
            bool exists = vModel.Id.IsAssigned();

            return(CreateViewModelEntityDefinition(vModel)
                   .UseDataContextUpdate(input => exists, input => output => input.Id == output.Id)
                   .UseDataContextCreate(input => !exists, output => output.Id, input => Guid.NewGuid())
                   .AddNavigation(i => i.Value, o => o.Name)
                   .AddSimple(i => languageCache.Get(i.Language), o => o.LocalizationId)
                   .GetFinal());
        }
示例#27
0
 private VmDescription CreateDescription(string language, string value, VmConnectionInput vModel, DescriptionTypeEnum typeEnum, bool isEmpty = false)
 {
     return(new VmDescription
     {
         Description = isEmpty ? null : value,
         TypeId = typesCache.Get <DescriptionType>(typeEnum.ToString()),
         OwnerReferenceId = vModel.MainEntityId,
         OwnerReferenceId2 = vModel.ConnectedEntityId,
         LocalizationId = languageCache.Get(language)
     });
 }
示例#28
0
        public override ServiceProducerAdditionalInformation TranslateVmToEntity(VmOpenApiLanguageItem vModel)
        {
            var definition = CreateViewModelEntityDefinition(vModel)
                             .DisableAutoTranslation()
                             .UseDataContextLocalizedUpdate(i => vModel.OwnerReferenceId.IsAssigned(), i => o => i.OwnerReferenceId == o.ServiceProducerId && i.Id == o.Id,
                                                            s => s.UseDataContextCreate(x => true));

            definition.AddNavigation(i => i.Value, o => o.Text);
            definition.AddSimple(i => languageCache.Get(i.Language), o => o.LocalizationId);
            return(definition.GetFinal());
        }
        public override PostOfficeBoxName TranslateVmToEntity(VmOpenApiLanguageItem vModel)
        {
            var exists = vModel.Id.IsAssigned();

            return(CreateViewModelEntityDefinition(vModel)
                   .UseDataContextCreate(i => !exists)
                   .UseDataContextUpdate(i => exists, i => o => i.OwnerReferenceId == o.AddressPostOfficeBoxId, e => e.UseDataContextCreate(x => true))
                   .AddNavigation(i => i.Value, o => o.Name)
                   .AddSimple(i => languageCache.Get(i.Language), o => o.LocalizationId)
                   .GetFinal());
        }
        public override ServiceServiceChannelDescription TranslateVmToEntity(VmLocalizedDescription vModel)
        {
            Guid languageId = languageCache.Get(vModel.Language.ToString());

            return(CreateViewModelEntityDefinition <ServiceServiceChannelDescription>(vModel)
                   .UseDataContextUpdate(i => true, i => o => (i.OwnerReferenceId == o.ServiceId) && (i.OwnerReferenceId2 == o.ServiceChannelId) && (i.TypeId == o.TypeId) && (languageId == o.LocalizationId)
                                         , def => def.UseDataContextCreate(i => true))
                   .AddNavigation(input => input.Description, output => output.Description)
                   .AddSimple(input => input.TypeId, output => output.TypeId)
                   .AddSimple(i => languageId, o => o.LocalizationId)
                   .GetFinal());
        }