예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("city_id,country_id,region_id,name")] City city)
        {
            if (id != city.city_id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(city);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CityExists(city.city_id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(city));
        }
예제 #2
0
 public async Task Update(City city)
 {
     _context.Update(city);
     await _context.SaveChangesAsync();
 }