public static CustomProductViewModel Convert(CustomProduct product) { CustomProductViewModel model = new CustomProductViewModel(); model.Id = product.Id; model.CategoryId = product.CategoryId; model.Name = product.Name; model.Description = product.Description; model.Subtitle = product.Subtitle; model.ImageSrc = product.ImageSrc; model.Price = product?.Price; model.IsOnSale = product.IsOnSale; model.IsInStock = product.IsInStock; model.Type = product.Type; model.Category = CategoryConverter.Convert(product.Category); if (product.MixCategories != null) { model.MixCategories = MixCategoryConverter.ConvertList(product.MixCategories); } model.Tags = TagConverter.ConvertList(product.Tags); if (product.SelectOptions != null) { model.SelectOptions = CustomSelectOptionConverter.ConvertList(product.SelectOptions); } return(model); }
public static ProductViewModel Convert(Product product) { ProductViewModel model = new ProductViewModel(); model.Id = product.Id; model.CategoryId = product.CategoryId; model.Name = product.Name; model.Description = product.Description; model.Subtitle = product.Subtitle; model.ImageSrc = product?.ImageSrc; model.IsOnSale = product.IsOnSale; model.IsInStock = product.IsInStock; model.ProductDetails = ProductDetailsConverter.ConvertList(product.ProductDetails); model.Category = CategoryConverter.Convert(product?.Category); model.Tags = TagConverter.ConvertList(product?.Tags); return(model); }