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); }
public static ShippingPrices ModelToEntity(this ShippingPricesViewModel shippingPrices) { return(new ShippingPrices { Id = shippingPrices.Id, OriginCity = shippingPrices.OriginCity, DestinationCity = shippingPrices.DestinationCity, CostPerKilo = shippingPrices.CostPerKilo }); }