コード例 #1
0
        public async Task <IActionResult> Create([Bind("OfficerID,LastName,FirstName,Years,Status,Rank")] Officer officer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(officer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(officer));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("AchievementID,SolderID,Description,Battle,Reward")] Achievement achievement)
        {
            if (ModelState.IsValid)
            {
                _context.Add(achievement);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(achievement));
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("UnitID,Name,Numbers,OfficerID")] Unit unit)
        {
            if (ModelState.IsValid)
            {
                _context.Add(unit);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OfficerID"] = new SelectList(_context.Officers, "OfficerID", "OfficerID", unit.OfficerID);
            return(View(unit));
        }
コード例 #4
0
        public async Task <IActionResult> Create([Bind("SoldierID,LastName,FirstName,Status,Age,Birthplace,UnitID")] Soldier soldier)
        {
            if (ModelState.IsValid)
            {
                _context.Add(soldier);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UnitID"] = new SelectList(_context.Units, "UnitID", "UnitID", soldier.UnitID);
            return(View(soldier));
        }