public async Task <IActionResult> Edit(int id, [Bind("Id,Descr,GermanyRegionId")] GermanyCity germanyCity) { if (id != germanyCity.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(germanyCity); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GermanyCityExists(germanyCity.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["GermanyRegionId"] = new SelectList(_context.GermanyRegions, "Id", "Descr", germanyCity.GermanyRegionId); return(View(germanyCity)); }
public async Task <IActionResult> Create([Bind("Id,Descr,GermanyRegionId")] GermanyCity germanyCity) { if (ModelState.IsValid) { _context.Add(germanyCity); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["GermanyRegionId"] = new SelectList(_context.GermanyRegions, "Id", "Descr", germanyCity.GermanyRegionId); return(View(germanyCity)); }