public async Task <IActionResult> Edit(int id, [Bind("Id,CountryName")] Countrylist countrylist) { if (id != countrylist.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(countrylist); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CountrylistExists(countrylist.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(countrylist)); }
public async Task <IActionResult> Add([Bind("Id,CountryName")] Countrylist countrylist) { if (ModelState.IsValid) { _context.Add(countrylist); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(countrylist)); }
private async Task AddCountryAsync() { var result = await _countryService.AddCountryAsync(CountryInput); if (result.Type != ResultType.Ok) { MessageBox.Show(result.Error); return; } Countrylist.Add(Mapper.Map <CountryDto, CountryViewModel>(result.Data)); }
private async Task RemoveCountryAsync() { var selectedCountry = Countrylist[SelectedCountryIndex]; var result = await _countryService.RemoveCountryAsync(selectedCountry.Id); if (result.Type != ResultType.Ok) { MessageBox.Show(result.Error); return; } Countrylist.RemoveAt(SelectedCountryIndex); }