예제 #1
0
        public async Task <IActionResult> Edit([Bind("Id, Name, Code")] CountryVM country)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    await service.UpdateCountryAsync(country.Adapt <CountryDTO>());
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CountryExists(country.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }

                return(RedirectToAction(nameof(Index)));
            }

            return(View(country));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("Name, Code")] CountryVM country)
        {
            if (ModelState.IsValid)
            {
                await service.AddCountryAsync(country.Adapt <CountryDTO>());

                return(RedirectToAction(nameof(Index)));
            }

            return(View(country));
        }