public async Task <IActionResult> AddSubCategoryToProduct([FromBody] ProductAndSubCategoryForAddDto entity)
        {
            var user = await _userRepo.GetUserByUserClaims(HttpContext.User);

            if (user == null)
            {
                return(Unauthorized("User is Unauthorized"));
            }

            var subCategory = await _subCategoryRepository.GetById(entity.SubCategoryId);

            if (subCategory == null)
            {
                return(BadRequest("Please check SubCategory exist."));
            }

            var product = await _productRepository.GetById(entity.ProductId);

            if (product == null)
            {
                return(BadRequest("Please check product exist."));
            }

            var dataForAdd = _mapper.Map <ProductAndSubCategory>(entity);

            if (await _subCategoriesAndProduct.AddSubCategoryToProduct(dataForAdd))
            {
                return(Ok());
            }
            throw new Exception("Error happen when Add SubCategory To Product");
        }
        public async Task <IActionResult> UpdateSubCategoryToProduct([FromQuery] int id, ProductAndSubCategoryForAddDto entity)
        {
            var user = await _userRepo.GetUserByUserClaims(HttpContext.User);

            if (user == null)
            {
                return(Unauthorized("User is Unauthorized"));
            }

            var subCategory = await _subCategoryRepository.GetById(entity.SubCategoryId);

            if (subCategory == null)
            {
                return(BadRequest("Please check SubCategory exist."));
            }

            var product = await _productRepository.GetById(entity.ProductId);

            if (product == null)
            {
                return(BadRequest("Please check product exist."));
            }

            var dataForUpdate = await _subCategoriesAndProduct.GetById(id);

            dataForUpdate.ProductId     = entity.ProductId;
            dataForUpdate.SubCategoryId = entity.SubCategoryId;

            if (await _subCategoriesAndProduct.UpdateSubCategoryWithProduct(dataForUpdate))
            {
                return(Ok());
            }
            throw new Exception("Error happen when Update SubCategory To Product");
        }