public static ProductViewModel ConvertToProductViewModel(this Product product) { var productViewModel = new ProductViewModel { Name = product.Name, ProductId = product.Id, RRP = string.Format("{0:C}", product.Price.RecommendedRetailPrice), SellingPrice = string.Format("{0:C}", product.Price.SellingPrice) }; if (product.Price.Discount > 0) productViewModel.Discount = string.Format("{0:C}", product.Price.Discount); if (product.Price.Savings < 1 && product.Price.Savings > 0) productViewModel.Savings = product.Price.Savings.ToString("#%"); return productViewModel; }
public static ProductViewModel ConvertToProductViewModel(this Model.Product product) { ProductViewModel viewModel = new ProductViewModel(); viewModel.ProductId = product.Id; viewModel.RRP = string.Format("{0:C}", product.Price.RRP); viewModel.SellingPrice = string.Format("{0:C}", product.Price.SellingPrice); if (product.Price.Discount > 0) viewModel.Discount = string.Format("{0:C}", product.Price.Discount); if (product.Price.Savings < 1 && product.Price.Savings > 0) { viewModel.Saving = product.Price.Savings.ToString("#%"); } return viewModel; }
public static ProductViewModel ConvertToProductViewModel(this Model.Product product) { ProductViewModel productViewModel = new ProductViewModel(); productViewModel.ProductId = product.ID; productViewModel.Name = product.Name; productViewModel.RRP = String.Format("{0:C}", product.Price.RRP); productViewModel.SellingPrice = String.Format("{0:C}", product.Price.SellingPrice); if (product.Price.Discount > 0) productViewModel.Discount = String.Format("{0:C}", product.Price.Discount); if (product.Price.Savings < 1 && product.Price.Savings > 0) productViewModel.Savings = product.Price.Savings.ToString("#%"); return productViewModel; }