public ProductFamilly(ProductType type, string famillyName, string image) { Type = type; FamillyName = famillyName; Image = image; }
public ProductFamilly(ProductType type, string famillyName) { Type = type; FamillyName = famillyName; }
private ProductType CreateProductType(ApplicationDbContext context, string name,string imageName = null) { ProductType type = context.ProductTypes.FirstOrDefault(x=> x.Name == name); if (type == null) { type = new ProductType(name); context.ProductTypes.Add(type); if(imageName != null) { type.Image = Path.Combine(Configurations.ProductsTypeAndFamillyIconsStockagesPath, imageName); } } return type; }
private ProductFamilly CreateProductFamily(ApplicationDbContext context, ProductType type, string name, string imageName = null) { ProductFamilly family = context.ProductFamillys.FirstOrDefault(x=> x.FamillyName == name); if (family == null) { family = new ProductFamilly(type, name); if(imageName != null) { family.Image = Path.Combine(Configurations.ProductsTypeAndFamillyIconsStockagesPath, imageName); } context.ProductFamillys.Add(family); } return family; }
public IActionResult CreateCategory(string categoryName) { var productCategory = new ProductType(categoryName); _context.ProductTypes.Add(productCategory); _context.SaveChanges(); return Ok(); }