Esempio n. 1
0
        public IActionResult PutGeneros([FromRoute] long id, [FromBody] Genero genero)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != genero.Id)
            {
                return(BadRequest());
            }

            var _genero = _generoRepository.Find(id);

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

            try
            {
                _generoRepository.Update(genero);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!_generoRepository.Exists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }