示例#1
0
        public Provider ViewModelToEntity(ProviderViewModel providerViewModel)
        {
            var provider = new Provider(providerViewModel.Id,
                                        providerViewModel.Name,
                                        providerViewModel.Document);

            if (providerViewModel.Addresses != null &&
                providerViewModel.Addresses.Any())
            {
                provider.AddAddresses(providerViewModel.Addresses.Select(a => _mapperAddress.ViewModelToEntity(a)).ToList());
            }

            if (providerViewModel.Contacts != null &&
                providerViewModel.Contacts.Any())
            {
                provider.AddContacts(providerViewModel.Contacts.Select(c => _mapperContact.ViewModelToEntity(c)).ToList());
            }

            return(provider);
        }