Exemple #1
0
        // PUT: api/Cities/5
        //[ResponseType(typeof(void))]
        public IHttpActionResult Put(int id, [FromBody] City city)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            try
            {
                _CityManager.Update(id, city);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!_CityManager.CityExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            catch (Exception e)
            {
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }