public async Task <OperationResult> EditProductGroupAsync(ProductGroupEntity productGroup) { var validationResult = await _validator.ValidateProductGroupAsync(productGroup); if (!validationResult.Succeeded) { return(validationResult); } var productGroupDbObject = await _repository.GetProductGroupByIdAsync(productGroup.Id); if (productGroupDbObject == null) { return(OperationResult.Failed(string.Format(ErrorMessageResource.ObjectNotFound, DisplayNameResource.ProductGroup))); } productGroupDbObject.Icon = productGroup.Icon; if (!await _repository.CheckHasProductsByIdAsync(productGroup.Id)) { productGroupDbObject.Title = productGroup.Title; productGroupDbObject.IsActive = productGroup.IsActive; productGroupDbObject.ParentId = productGroup.ParentId; productGroupDbObject.ProductGroupTypeId = productGroup.ProductGroupTypeId; productGroupDbObject.ProductGroupProvinces = productGroup.ProductGroupProvinces; } await _repository.EditProductGroupAsync(productGroupDbObject); return(OperationResult.Success()); }