示例#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();
 }