public static ApiProduct FromProduct(Product dataProduct) { var product = new ApiProduct() { Id = dataProduct.Id, Name = dataProduct.Name, Description = dataProduct.Description, Units = dataProduct.Units }; if (dataProduct.Variants != null) { product.Variants = dataProduct.Variants.Select(i => ApiVariant.FromVariant(i)).ToArray(); } return(product); }
public static ApiVariant FromVariant(Variant dataVariant) { var variant = new ApiVariant() { Id = dataVariant.Id, Brand = dataVariant.Brand, Product = dataVariant.Product.Id, Quantity = dataVariant.Quantity, Description = dataVariant.Description, Container = dataVariant.Container, ImagePath = dataVariant.ImagePath, PackagingType = dataVariant.PackagingType }; if (dataVariant.Sources != null) { variant.Sources = dataVariant.Sources.Select(i => ApiSource.FromSource(i)).ToArray(); } return(variant); }