コード例 #1
0
        public IHttpActionResult PutContato(long id, Contato contato)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != contato.ContatoID)
            {
                return(BadRequest());
            }

            ContatoDAO contatoDAO = new ContatoDAO();

            contatoDAO.Update(contato);


            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ContatoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }