Esempio n. 1
0
        public async Task <IActionResult> PutCity(City city)
        {
            //if (id != city.CityId)
            //{
            //    return BadRequest();
            //}

            _context.Entry(city).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                //if (!CityExists(id))
                //{
                //    return NotFound();
                //}
                //else
                //{
                throw;
                //}
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutCountry(int id, Country country)
        {
            if (id != country.CountryId)
            {
                return(BadRequest());
            }

            _context.Entry(country).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CountryExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }