예제 #1
0
        public void TestUpdate()
        {
            var ingrediente = new Ingrediente()
            {
                Id        = 1,
                Descricao = "Teste",
                Valor     = 300
            };

            _ingredienteBll.Update(ingrediente);

            _ingredienteRepositoryMock.Verify(x => x.Update(ingrediente), Times.Once());
        }
        public IActionResult Update(int id, [FromBody] Ingrediente ingrediente)
        {
            if (ingrediente == null || ingrediente.Id != id)
            {
                return(BadRequest());
            }

            var _ingrediente = _ingredienteBll.Find(id);

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

            _ingrediente.Descricao = ingrediente.Descricao;
            _ingrediente.Valor     = ingrediente.Valor;

            _ingredienteBll.Update(_ingrediente);

            return(new NoContentResult());
        }