public IActionResult CreateProduct([FromBody] ProductAddOrUpdDTO product)
        {
            try
            {
                if (product == null)
                {
                    return(BadRequest("Product object is null"));
                }
                if (!ModelState.IsValid)
                {
                    return(BadRequest("Invalid model object"));
                }

                var productEntity = _mapper.Map <Product>(product);
                productEntity.UserId = new Guid(User.Identity.Name);

                _repository.Product.CreateProduct(productEntity);
                _repository.Save();

                var createdProduct = _mapper.Map <ProductDTO>(productEntity);

                return(CreatedAtRoute("ProductById", new { id = createdProduct.Id }, createdProduct));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, $"Something went wrong inside CreateProduct action: {ex.Message}"));
            }
        }
        public IActionResult UpdateProduct(Guid id, [FromBody] ProductAddOrUpdDTO product)
        {
            try
            {
                if (product == null)
                {
                    return(BadRequest("Product object is null"));
                }
                if (!ModelState.IsValid)
                {
                    return(BadRequest("Invalid model object"));
                }

                var productEntity = _repository.Product.GetProductById(id);
                if (productEntity == null)
                {
                    return(NotFound());
                }

                _mapper.Map(product, productEntity);

                _repository.Product.UpdateProduct(productEntity);
                _repository.Save();

                return(NoContent());
            }
            catch (Exception ex)
            {
                return(StatusCode(500, $"Something went wrong inside UpdateProduct action: {ex.Message}"));
            }
        }