public ShippingAddressViewModel GetViewModel(ShippingAddress address) { var countryName = countryHelper.GetNameByID(address.CountryID); return(new ShippingAddressViewModel { ID = address.ID, AdditionalAddress = address.AdditionalAddress, CustomerID = address.CustomerID, CountryID = address.CountryID, CountryName = countryName, Address = address.Address, City = address.City, CompanyName = address.CompanyName, FirstName = address.FirstName, IsInvoiceAddress = address.IsInvoiceAddress, IsMainAddress = address.IsMainAddress, LastName = address.LastName, PostCode = address.PostCode }); }
public async Task <List <ShippingPricesViewModel> > GetShippingPricesViewModels(int priceTypeId) { List <ShippingPricesViewModel> resultList = new List <ShippingPricesViewModel>(); var shipprices = await context.ShippingPrices.Where(t => t.ShippingPriceTypeId == priceTypeId).ToListAsync(); foreach (var item in shipprices) { bool allow = await countryHelper.GetAllowedForShipping(item.CountryId); if (allow) { var vm = new ShippingPricesViewModel { Id = item.ID, CountryId = item.CountryId, CountryName = countryHelper.GetNameByID(item.CountryId), Name = item.Name, Price = item.Price, ShippingPriceTypeId = item.ShippingPriceTypeId }; resultList.Add(vm); } } return(resultList); }