Beispiel #1
0
        public async Task <ActionResultResponse> Delete(string tenantId, string productAttributeId)
        {
            var info = await _attributeRepository.GetInfo(productAttributeId);

            if (info == null)
            {
                return(new ActionResultResponse(-1, _warehouseResourceService.GetString("Product attribute does not exists.")));
            }

            if (info.TenantId != tenantId)
            {
                return(new ActionResultResponse(-2, _sharedResourceService.GetString(ErrorMessage.NotHavePermission)));
            }

            var isUsedInproductAttributeValue = await _attributeValueRepository.CheckExistsByProductAttributeId(productAttributeId);

            if (isUsedInproductAttributeValue)
            {
                return(new ActionResultResponse(-3,
                                                _warehouseResourceService.GetString("Product attribute used by product attribute value. You can not delete product attribute.")));
            }

            var isProductValueExists = await _productAttributeRepository.CheckExistProductAttributeId(productAttributeId, tenantId);

            if (isProductValueExists)
            {
                return(new ActionResultResponse(-2, _warehouseResourceService.GetString("This product attribute has been used by product. You can not delete this product attribute.")));
            }

            var result = await _attributeRepository.Delete(productAttributeId);

            await _attributeTranslationRepository.Delete(productAttributeId);

            return(new ActionResultResponse(result, _warehouseResourceService.GetString("Delete product attribute successful.")));
        }