Пример #1
0
        public IActionResult Put([PositiveInteger] int id, [FromBody] ProductBasicInfoPutDTO modifiedProduct)
        {
            // Se actualiza un registro.
            new ProductSC().UpdateProduct(id, modifiedProduct);

            return(NoContent());
        }
Пример #2
0
        public IActionResult Put(int id, [FromBody] ProductBasicInfoPutDTO modifiedProduct)
        {
            Product dataBaseProduct = new ProductSC().GetProductById(id);

            if (dataBaseProduct == null)
            {
                return(NotFound());
            }

            try
            {
                //TODO: Check if it is possible to pass the dataBaseProduct insted of the id.
                new ProductSC().UpdateProduct(id, modifiedProduct);
            }
            catch (Exception ex) when(ExceptionTypes.IsSqlException(ex))
            {
                string message = SqlExceptionMessages.GetCustomSqlExceptionMessage(ex.InnerException as SqlException);

                if (message != null)
                {
                    return(Conflict(message));
                }

                throw;
            }

            return(NoContent());
        }