コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("SettlementId,Iddistrict,Name,Type,Population")] Settlements settlements)
        {
            if (id != settlements.SettlementId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(settlements);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SettlementsExists(settlements.SettlementId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index", "Settlements", new { i = settlements.Iddistrict }));
            }
            ViewData["IdSelectedDistrict"] = settlements.Iddistrict;
            return(View(settlements));
        }
コード例 #2
0
        public async Task <ActionResult> UpdateCountryInfo([FromBody] CountryEntity countryEntity)
        {
            try
            {
                CountryEntity updatedCountry = _countryRepository.UpdateCountryInfo(countryEntity);
                _context.Update(updatedCountry);
                await _countryRepository.Save();

                return(NoContent());
            }
            catch
            {
                return(BadRequest());
            }
        }