public ITranslationDefinitions <TIn, ServiceChannelVersioned> AddAllAreasDefinition <TIn>(ITranslationDefinitions <TIn, ServiceChannelVersioned> definition, Guid?AreaInformationTypeId, Guid?id) where TIn : IVmAreaInformation
 {
     if (typesCache.Compare <AreaInformationType>(AreaInformationTypeId, AreaInformationTypeEnum.AreaType.ToString()))
     {
         return(definition
                .AddCollection(
                    i => i.BusinessRegions.Union(i.HospitalRegions).Union(i.Provinces).Select(x => new VmListItem
         {
             Id = x,
             OwnerReferenceId = id
         }), o => o.Areas)
                .AddCollection(
                    i => i.Municipalities.Select(x => new VmListItem
         {
             Id = x,
             OwnerReferenceId = id
         }), o => o.AreaMunicipalities));
     }
     else
     {
         definition.AddCollection(i => new List <VmListItem>()
         {
         }, o => o.Areas, TranslationPolicy.FetchData);
         definition.AddCollection(i => new List <VmListItem>()
         {
         }, o => o.AreaMunicipalities, TranslationPolicy.FetchData);
     }
     return(definition);
 }
 public ITranslationDefinitions <TIn, ServiceChannelVersioned> AddEmailsDefinition <TIn>(ITranslationDefinitions <TIn, ServiceChannelVersioned> definition) where TIn : IEmails
 {
     return(definition.AddCollection(input =>
     {
         var number = 1;
         input.Emails.ForEach(email => email.OrderNumber = number++);
         return input.Emails;
     }, output => output.Emails));
 }
 public ITranslationDefinitions <TIn, ServiceChannelVersioned> AddPhonesDefinition <TIn>(ITranslationDefinitions <TIn, ServiceChannelVersioned> definition) where TIn : IPhoneNumbers
 {
     return(definition.AddCollection(input =>
     {
         var number = 1;
         input.PhoneNumbers.ForEach(phoneNumber => phoneNumber.OrderNumber = number++);
         return input.PhoneNumbers;
     }, output => output.Phones));
 }
        public ITranslationDefinitions <TIn, ServiceChannelVersioned> AddAttachmentsDefinition <TIn>(ITranslationDefinitions <TIn, ServiceChannelVersioned> definition, IAttachments model, Guid?referenceId) where TIn : IAttachments
        {
            var order = 1;

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

            return(definition.AddCollection(input => input.UrlAttachments, output => output.Attachments));
        }
        public ITranslationDefinitions <TIn, ServiceChannelVersioned> AddLanguagesDefinition <TIn>(ITranslationDefinitions <TIn, ServiceChannelVersioned> definition) where TIn : ILanguages
        {
            var languageCounter = 0;

            return(definition.AddCollection(
                       i => i.Languages.Select(x => new VmListItem {
                Id = x,
                OrderNumber = languageCounter++,
                OwnerReferenceId = i.Id
            }),
                       o => o.Languages
                       ));
        }
Ejemplo n.º 6
0
        public ServiceChannelTranslationDefinitionHelper AddLanguagesDefinition <TIn>(ITranslationDefinitions <TIn, ServiceChannelVersioned> definition) where TIn : ILanguages
        {
            var languageCounter = 0;

            definition.AddCollection(
                i => i.Languages?.Select(x => new VmListItem {
                Id               = x,
                OrderNumber      = languageCounter++,
                OwnerReferenceId = i.Id
            }),
                o => o.Languages, TranslationPolicy.FetchData
                );
            return(this);
        }
Ejemplo n.º 7
0
 private void SetStep2Translation(ITranslationDefinitions <VmService, ServiceVersioned> definition, VmService model)
 {
     model.Step2Form?.ServiceClasses?.ForEach(i => i.OwnerReferenceId    = model.Id);
     model.Step2Form?.OntologyTerms?.ForEach(i => i.OwnerReferenceId     = model.Id);
     model.Step2Form?.LifeEvents?.ForEach(i => i.OwnerReferenceId        = model.Id);
     model.Step2Form?.IndustrialClasses?.ForEach(i => i.OwnerReferenceId = model.Id);
     definition
     .AddCollection(i => i.Step2Form.TargetGroups.Select(x => new VmTargetGroupListItem {
         Id = x, OwnerReferenceId = model.Id
     }).Concat(
                        i.Step2Form.OverrideTargetGroups.Select(x => new VmTargetGroupListItem {
         Id = x, Override = true, OwnerReferenceId = model.Id
     })),
                    o => o.ServiceTargetGroups)
     .AddCollection(i => i.Step2Form.ServiceClasses, o => o.ServiceServiceClasses)
     .AddCollection(i => i.Step2Form.OntologyTerms, o => o.ServiceOntologyTerms)
     .AddCollection(i => i.Step2Form.LifeEvents, o => o.ServiceLifeEvents)
     .AddCollection(i => i.Step2Form.IndustrialClasses, o => o.ServiceIndustrialClasses)
     .AddCollection(i => i.Step2Form.KeyWords.Select(x => new VmKeywordItem()
     {
         Id = x, OwnerReferenceId = model.Id
     }).Concat(i.Step2Form.NewKeyWords.Where(j => !string.IsNullOrEmpty(j.Name))), o => o.ServiceKeywords);
 }
Ejemplo n.º 8
0
 public ITranslationDefinitions <TIn, TOut> AddLanguageAvailabilitiesDefinition <TIn, TOut, TLanguagesAvailability>(ITranslationDefinitions <TIn, TOut> definition, ILanguageOrderCache orderCache) where TIn : IMultilanguagedEntity <TLanguagesAvailability> where TOut : ILanguagesAvailabilities where TLanguagesAvailability : LanguageAvailability
 {
     return(definition.AddCollection <ILanguageAvailability, VmLanguageAvailabilityInfo>(
                i => i.LanguageAvailabilities.OrderBy(x => orderCache.Get(x.LanguageId)),
                o => o.LanguagesAvailabilities));
 }
Ejemplo n.º 9
0
        private void SetStep1Translation(ITranslationDefinitions <VmOrganizationModel, OrganizationVersioned> definition, VmOrganizationModel organization)
        {
            var model = organization.Step1Form;
            var names = new List <VmName>()
            {
                new VmName {
                    Name = model.OrganizationName, TypeId = typesCache.Get <NameType>(NameTypeEnum.Name.ToString()), OwnerReferenceId = organization.Id
                }
            };

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

            var descriptions = new List <VmDescription>()
            {
                new VmDescription {
                    Description = model.Description, TypeId = typesCache.Get <DescriptionType>(DescriptionTypeEnum.Description.ToString()), OwnerReferenceId = organization.Id
                },
            };

            definition.AddNavigation(i => i.Step1Form.Business, o => o.Business);

            if (model.OrganizationTypeId.IsAssigned() && typesCache.Compare <AreaInformationType>(model.AreaInformationTypeId, AreaInformationTypeEnum.AreaType.ToString()))
            {
                if (typesCache.Compare <OrganizationType>(model.OrganizationTypeId, OrganizationTypeEnum.State.ToString()) ||
                    typesCache.Compare <OrganizationType>(model.OrganizationTypeId, OrganizationTypeEnum.Organization.ToString()) ||
                    typesCache.Compare <OrganizationType>(model.OrganizationTypeId, OrganizationTypeEnum.Company.ToString()) ||
                    typesCache.Compare <OrganizationType>(model.OrganizationTypeId, OrganizationTypeEnum.RegionalOrganization.ToString()))
                {
                    var areas = model.BusinessRegions.Union(model.HospitalRegions).Union(model.Provinces);
                    definition.AddCollection(i => areas.Select(x => new VmListItem {
                        Id = x, OwnerReferenceId = organization.Id
                    }), o => o.OrganizationAreas);
                    definition.AddCollection(i => i.Step1Form.Municipalities.Select(x => new VmListItem {
                        Id = x, OwnerReferenceId = organization.Id
                    }), o => o.OrganizationAreaMunicipalities);
                }
            }
            else
            {   //Remove Areas
                definition.AddCollection(i => new List <VmListItem>()
                {
                }, o => o.OrganizationAreas);
                definition.AddCollection(i => new List <VmListItem>()
                {
                }, o => o.OrganizationAreaMunicipalities);
            }

            var nameType = new VmDispalyNameType {
                NameTypeId = model.DisplayNameId, OwnerReferenceId = organization.Id
            };

            var order = 1;

            model.Emails.ForEach(email => email.OrderNumber = order++);
            order = 1;
            model.PhoneNumbers.ForEach(phone => phone.OrderNumber = order++);
            order = 1;
            model.VisitingAddresses.ForEach(item => item.OrderNumber = order++);
            order = 1;
            model.PostalAddresses.ForEach(item => item.OrderNumber = order++);

            var defaultAreaInformationTypeId = typesCache.Get <AreaInformationType>(AreaInformationTypeEnum.WholeCountry.ToString());

            definition
            .AddSimple(i => i.Step1Form.OrganizationTypeId, o => o.TypeId)
            .AddSimple(i => i.Step1Form.AreaInformationTypeId.IsAssigned() ? i.Step1Form.AreaInformationTypeId : defaultAreaInformationTypeId, output => output.AreaInformationTypeId)
            .AddSimple(i => i.Step1Form.ParentId, o => o.ParentId)
            .AddSimple(i => i.Step1Form.Municipality?.Id, o => o.MunicipalityId)
            //.AddSimple(i => i.Step1Form.DisplayNameId, o => o.DisplayNameTypeId)
            .AddNavigation(i => i.Step1Form.OrganizationId, o => o.Oid)
            .AddLocalizable(i => nameType, o => o.OrganizationDisplayNameTypes)
            .AddCollectionWithKeep(i => names, o => o.OrganizationNames, TranslationPolicy.FetchData, x => x.LocalizationId != RequestLanguageId)
            .AddCollectionWithKeep(i => descriptions, o => o.OrganizationDescriptions, TranslationPolicy.FetchData, x => x.LocalizationId != RequestLanguageId);

            //model.ShowContacts
            definition
            .AddCollection(i => i.Step1Form.Emails, o => o.OrganizationEmails)
            .AddCollection(i => i.Step1Form.PhoneNumbers, o => o.OrganizationPhones)
            .AddCollection(i => i.Step1Form.WebPages, o => o.OrganizationWebAddress);

            //model.ShowPostalAddress || model.ShowVisitingAddress)
            var addresses = new List <VmAddressSimple>();

            addresses = model.PostalAddresses.Any() ? addresses.Concat(model.PostalAddresses.Where(x =>
                                                                                                   (x.PostalCode != null && x.StreetType != AddressTypeEnum.Foreign.ToString()) ||
                                                                                                   x.StreetType == AddressTypeEnum.Foreign.ToString())).ToList() : addresses;
            addresses = model.VisitingAddresses.Any() ? addresses.Concat(model.VisitingAddresses.Where(x =>
                                                                                                       (x.PostalCode != null && x.StreetType != AddressTypeEnum.Foreign.ToString()) ||
                                                                                                       x.StreetType == AddressTypeEnum.Foreign.ToString())).ToList() : addresses;
            addresses.ForEach(x => x.OwnerReferenceId = organization.Id);
            definition.AddCollection(i => addresses, o => o.OrganizationAddresses);
        }
 public ITranslationDefinitions <ServiceChannelVersioned, TOut> AddAttachmentsDefinition <TOut>(ITranslationDefinitions <ServiceChannelVersioned, TOut> definition, LanguageCode requestLanguageCode) where TOut : IAttachments
 {
     return(definition.AddCollection(input => languageCache.FilterCollection(input.Attachments.Select(i => i.Attachment).OrderBy(i => i.OrderNumber).ThenBy(i => i.Modified), requestLanguageCode), output => output.UrlAttachments));
 }
 public ITranslationDefinitions <ServiceChannelVersioned, TOut> AddWebPagesDefinition <TOut>(ITranslationDefinitions <ServiceChannelVersioned, TOut> definition, LanguageCode languageCode) where TOut : IWebPages
 {
     return(definition.AddCollection(i => i.WebPages.OrderBy(x => x.WebPage.OrderNumber).ThenBy(x => x.WebPage.Created).Where(x => languageCache.Get(languageCode.ToString()) == x.WebPage.LocalizationId), o => o.WebPages));
 }
 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.Where(j => !string.IsNullOrEmpty(j.UrlAddress)), o => o.WebPages, true));
 }
 public ITranslationDefinitions <ServiceChannelVersioned, TOut> AddEmailsDefinition <TOut>(ITranslationDefinitions <ServiceChannelVersioned, TOut> definition, LanguageCode languageCode) where TOut : IEmails
 {
     return(definition.AddCollection(input => languageCache.FilterCollection(input.Emails.Select(x => x.Email), languageCode).OrderBy(x => x.OrderNumber).ThenBy(x => x.Created),
                                     output => output.Emails));
 }
 public ITranslationDefinitions <ServiceChannelVersioned, TOut> AddPhonesFaxTypeDefinition <TOut>(ITranslationDefinitions <ServiceChannelVersioned, TOut> definition, LanguageCode languageCode) where TOut : IFaxNumbers
 {
     return(definition.AddCollection(input => languageCache.FilterCollection(input.Phones.Where(x => x.Phone.TypeId == typesCache.Get <PhoneNumberType>(PhoneNumberTypeEnum.Fax.ToString())).Select(x => x.Phone), languageCode).OrderBy(x => x.OrderNumber).ThenBy(x => x.Created),
                                     output => output.FaxNumbers));
 }