示例#1
0
        public async Task <IActionResult> Create([Bind("Id,Name")] Army army)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    await _armyService.Create(army);

                    return(RedirectToAction(nameof(Index)));
                }
            }
            catch (Exception)
            {
                throw;
            }

            var castleList = _castleService.GetAll().OrderBy(x => x.Name);

            ViewData["CastleId"] = new SelectList(castleList, "Id", "Id");
            return(View(army));
        }
示例#2
0
        public async Task <ActionResult <Army> > PostArmy(Army army)
        {
            await _armyService.Create(army);

            return(CreatedAtAction("GetArmy", new { id = army.Id }, army));
        }