예제 #1
0
        public async Task <IActionResult> Create([Bind("NationId,NationName")] Nation nation)
        {
            if (ModelState.IsValid)
            {
                _context.Add(nation);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(nation));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("TankTypeId,TankTypeName")] TankType tankType)
        {
            if (ModelState.IsValid)
            {
                _context.Add(tankType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(tankType));
        }
예제 #3
0
        public async Task <IActionResult> Create([Bind("TankId,TankName,TankTier,FirePower,Survivability,Mobility,Concealment,Spotting,TankTypeId,NationId")] Tank tank)
        {
            if (ModelState.IsValid)
            {
                _context.Add(tank);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["NationId"]   = new SelectList(_context.Nations, "NationId", "NationId", tank.NationId);
            ViewData["TankTypeId"] = new SelectList(_context.TankTypes, "TankTypeId", "TankTypeId", tank.TankTypeId);
            return(View(tank));
        }