Beispiel #1
0
 public static ProductForm FromModel(Product model)
 {
     return(new ProductForm {
         ID = model.ID,
         Name = model.Name,
         Description = model.Description,
         Color = model.Color,
         Price = model.Price.ToString(),
         Discount = model.Discount.ToString(),
         DiscountFrom = model.DiscountFrom,
         DiscountUntil = model.DiscountUntil,
         VendorID = model.VendorID,
         Images = model.ProductImages is null ? new List <ImageForm>() : model.ProductImages.Select(i => ImageForm.FromModel(i.Image)).ToList(),
         MainImageID = model.MainProductImage is null ? 0 : model.MainProductImage.Image.ID,
         Categories = model.Categories.Select(c => c.ID).ToList()
     });