//        [InlineData(StreetAddressTypeEnum.Both, AddressTypeEnum.Postal, "street", "pobox", "11D495DE-E1E7-4B57-BC86-20A87BA83324")]
        //        [InlineData(StreetAddressTypeEnum.Both, AddressTypeEnum.Visiting, "street", "", "11D495DE-E1E7-4B57-BC86-20A87BA83324")]
        //        [InlineData(StreetAddressTypeEnum.Both, AddressTypeEnum.Postal, "", "pobox", "11D495DE-E1E7-4B57-BC86-20A87BA83324")]
        //        [InlineData(StreetAddressTypeEnum.Both, AddressTypeEnum.Visiting, "", "", "11D495DE-E1E7-4B57-BC86-20A87BA83324")]
        public void TranslateAddress(AddressTypeEnum type, AddressCharacterEnum addressCharacter, string street, string pobox, string postalCodeId)
        {
            var model = CreateModel();

            model.AddressCharacter = addressCharacter;
            model.StreetType       = type.ToString();
            //            model.Street = street;
            var poBox = new Dictionary <string, string>();

            poBox.Add(LanguageCode.fi.ToString(), pobox);
            model.PoBox      = poBox;
            model.PostalCode = string.IsNullOrEmpty(postalCodeId)
                ? null
                : new VmPostalCode {
                Id = postalCodeId.ParseToGuid() ?? Guid.Empty
            };

            var toTranslate = new List <VmAddressSimple>()
            {
                model
            };

            var translations = RunTranslationModelToEntityTest <VmAddressSimple, Address>(translators, toTranslate, unitOfWorkMock);
            var translation  = translations.First();

            Assert.Equal(toTranslate.Count, translations.Count);
            CheckTranslation(model, translation, type);
        }
Beispiel #2
0
 private AddressType(AddressTypeEnum @enum)
 {
     AddressTypeID = (int)@enum;
     Name          = @enum.ToString();
     ModifiedDate  = DateTime.Now;
     rowguid       = new Guid();
     //this.People = new HashSet<Person>();
 }
Beispiel #3
0
 public static AddressTypeLookup GetAddressTypeLookup(AddressTypeEnum addressTypeEnum)
 {
     return(new AddressTypeLookup
     {
         Id = (int)addressTypeEnum,
         AddressTypeId = (int)addressTypeEnum,
         Name = AddressTypeName.FromString(addressTypeEnum.ToString()),
         Desc = addressTypeEnum + " Description"
     });
 }
Beispiel #4
0
        public static TModel CreateAddressVm <TModel>(AddressTypeEnum addressType)
            where TModel : IV7VmOpenApiAddressInVersionBase, new()
        {
            var vm = new TModel()
            {
                Type    = AddressCharacterEnum.Postal.ToString(),
                SubType = addressType.ToString(),
                Country = LanguageCode.fi.ToString(),
            };

            switch (addressType)
            {
            case AddressTypeEnum.Street:
                vm.StreetAddress = new VmOpenApiAddressStreetWithCoordinatesIn
                {
                    Street                = CreateLanguageItemList(),
                    StreetNumber          = "1",
                    PostalCode            = POSTAL_CODE,
                    Municipality          = MUNICIPALITY,
                    AdditionalInformation = CreateLanguageItemList()
                };
                break;

            case AddressTypeEnum.PostOfficeBox:
                vm.PostOfficeBoxAddress = new VmOpenApiAddressPostOfficeBoxIn
                {
                    PostOfficeBox         = CreateLanguageItemList(),
                    PostalCode            = POSTAL_CODE,
                    Municipality          = MUNICIPALITY,
                    AdditionalInformation = CreateLanguageItemList()
                };
                break;

            case AddressTypeEnum.Foreign:
                vm.ForeignAddress = CreateLanguageItemList();
                break;

            default:
                break;
            }

            return(vm);
        }
Beispiel #5
0
        public override VmAddressSimple TranslateEntityToVm(Address entity)
        {
            AddressTypeEnum type       = GetAddressType(entity);
            var             definition = CreateEntityViewModelDefinition <VmAddressSimple>(entity)
                                         .AddPartial(i => i, o => o as VmAddressSimpleBase)
                                         .AddSimple(input => input.Id, output => output.Id)
                                         .AddNavigation(input => input.Country != null ? input.Country : null, output => output.Country)
                                         .AddCollection(input => GetCoordinates(input.Coordinates), output => output.Coordinates)
                                         .AddNavigation(input => type.ToString(), output => output.StreetType);

            switch (type)
            {
            case AddressTypeEnum.PostOfficeBox:
                definition.AddDictionary(i => i.AddressAdditionalInformations, o => o.AdditionalInformation, k => languageCache.GetByValue(k.LocalizationId));
                definition.AddPartial(i => i.AddressPostOfficeBoxes.FirstOrDefault(), o => o);
                break;

            case AddressTypeEnum.Street:
                definition.AddDictionary(i => i.AddressAdditionalInformations, o => o.AdditionalInformation, k => languageCache.GetByValue(k.LocalizationId));
                definition.AddPartial(i => i.AddressStreets.FirstOrDefault(), o => o);
                break;

            case AddressTypeEnum.Foreign:
                definition.AddPartial(i => i.AddressForeigns.FirstOrDefault(), o => o);
                break;

            case AddressTypeEnum.NoAddress:
                definition.AddDictionary(i => i.AddressAdditionalInformations, o => o.NoAddressAdditionalInformation, k => languageCache.GetByValue(k.LocalizationId)
                                         );
                break;

            default:
                break;
            }
            var model = definition.GetFinal();

            return(model);
        }