public Client ViewModelToEntity(ClientViewModel clientViewModel) { var client = new Client(clientViewModel.Id, clientViewModel.Name, clientViewModel.Document); if (clientViewModel.Addresses != null && clientViewModel.Addresses.Any()) { client.AddAddresses(clientViewModel.Addresses.Select(a => _mapperAddress.ViewModelToEntity(a)).ToList()); } if (clientViewModel.Contacts != null && clientViewModel.Contacts.Any()) { client.AddContacts(clientViewModel.Contacts.Select(c => _mapperContact.ViewModelToEntity(c)).ToList()); } return(client); }
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); }