Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        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);
        }