예제 #1
0
        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 CreateFamily(Guid categoryId, string familyName)
 {
     var productCategory = _context.ProductTypes.FirstOrDefault(x => x.Id == categoryId);
     if (productCategory == null)
     {
         return StatusCode(400);
     }
     var productFamily = new ProductFamilly(productCategory, familyName);
     _context.ProductFamillys.Add(productFamily);
     _context.SaveChanges();
     return Ok();
 }