Пример #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Army army)
        {
            if (id != army.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await _armyService.Update(army);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ArmyExists(army.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            return(View(army));
        }
Пример #2
0
        public async Task <IActionResult> PutArmy(int id, Army army)
        {
            if (id != army.Id)
            {
                return(BadRequest());
            }

            try
            {
                await _armyService.Update(army);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ArmyExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }