public ActionResult <Product> AddProduct(ProductAddDto productAddDto) { var product = _mapper.Map <Product>(productAddDto); try { _repository.AddProduct(product); if (_repository.SaveChanges()) { return(CreatedAtAction(nameof(GetProductById), new { Id = product.Id }, product)); } } catch { return(StatusCode(StatusCodes.Status500InternalServerError, "Database Failure")); } return(BadRequest()); }