public ProductViewModel(SearchUpcItemInfo itemInfo) { ProductName = itemInfo.ProductName; ImageUrl = itemInfo.ImageUrl; Price = ConvertToPrice(itemInfo); Currency = GetCurrencySymbol(itemInfo.Currency); Quantity = 1; DatePurchased = DateTime.UtcNow; }
public static decimal ConvertToPrice(SearchUpcItemInfo itemInfo) { decimal price; return decimal.TryParse(itemInfo.Price, out price) ? price : default(decimal); }