public ServiceActionResult AddProductCategory(ProductCategoryDto productCategory) { if (productCategory == null) { return(new ServiceActionResult(ActionStatus.NotSuccessfull, "Product category cannot be null")); } if (productCategory.CategoryName.IsNullOrEmpty()) { return(new ServiceActionResult(ActionStatus.NotSuccessfull, "Category name cannot be null or empty")); } if (productCategory.ShopGuid.IsEmptyGuid()) { return(new ServiceActionResult(ActionStatus.NotSuccessfull, "Shop guid cannot be empty")); } Shop shop = _shopRepository.GetShopById(productCategory.ShopGuid); if (shop == null) { return(new ServiceActionResult(ActionStatus.NotSuccessfull, "Provided shop doesn't exist")); } ProductCategory category = _productCategoryRepository.GetProductCategoryByName(productCategory.ShopGuid, productCategory.CategoryName); if (category != null) { return(new ServiceActionResult(ActionStatus.NotSuccessfull, "Product category already exist")); } ProductCategory entity = productCategory.Map(); entity.ProductCategoryShop = shop; _productCategoryRepository.AddToDatabase(entity); return(ServiceActionResult.Successfull); }