예제 #1
0
        public async Task <IActionResult> Create([Bind("Id,Name,CountryId,Arm")] Player player)
        {
            if (ModelState.IsValid)
            {
                _context.Add(player);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CountryId"] = new SelectList(_context.Country, "Id", "CountryName", player.CountryId);
            return(View(player));
        }
        public async Task <IActionResult> Create([Bind("Id,PlayerId,RacketId")] PlayerRackets playerRackets)
        {
            if (ModelState.IsValid)
            {
                _context.Add(playerRackets);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Id"]       = new SelectList(_context.Racket, "Id", "Id", playerRackets.Id);
            ViewData["PlayerId"] = new SelectList(_context.Player, "Id", "Name", playerRackets.PlayerId);
            return(View(playerRackets));
        }
예제 #3
0
        public async Task <IActionResult> Create([Bind("Id,BladeId,FhrubberId,BhrubberId")] Racket racket)
        {
            if (ModelState.IsValid)
            {
                _context.Add(racket);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BhrubberId"] = new SelectList(_context.Rubber, "Id", "RubberName", racket.BhrubberId);
            ViewData["BladeId"]    = new SelectList(_context.Blade, "Id", "BladeName", racket.BladeId);
            ViewData["FhrubberId"] = new SelectList(_context.Rubber, "Id", "RubberName", racket.FhrubberId);
            return(View(racket));
        }
예제 #4
0
        public async Task <IActionResult> Create(int countryId, [Bind("Id,Name,CountryId,Arm")] Player player)
        {
            player.CountryId = countryId;
            if (ModelState.IsValid)
            {
                _context.Add(player);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", "Players", new { id = countryId, name = _context.Country.Where(c => c.Id == countryId).FirstOrDefault().CountryName }));
            }
            // ViewData["CountryId"] = new SelectList(_context.Country, "Id", "CountryName", player.CountryId);
            // return View(player);

            return(RedirectToAction("Index", "Players", new { id = countryId, name = _context.Country.Where(c => c.Id == countryId).FirstOrDefault().CountryName }));
        }
예제 #5
0
        public async Task <IActionResult> Create([Bind("Id,CountryName")] Country country)
        {
            if (ModelState.IsValid)
            {
                if (CountryExists(country.CountryName))
                {
                    return(RedirectToAction(nameof(Index)));
                }
                _context.Add(country);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(country));
        }
예제 #6
0
        public async Task <IActionResult> Create([Bind("Id,Player1Id,Player2Id,Racket1Id,Racket2Id,Result,Score,GameDate")] Game game)
        {
            if (ModelState.IsValid)
            {
                _context.Add(game);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Player1Id"] = new SelectList(_context.Player, "Id", "Name", game.Player1Id);
            ViewData["Player2Id"] = new SelectList(_context.Player, "Id", "Name", game.Player2Id);
            ViewData["Racket1Id"] = new SelectList(_context.PlayerRackets, "Id", "Id", game.Racket1Id);
            ViewData["Racket2Id"] = new SelectList(_context.PlayerRackets, "Id", "Id", game.Racket2Id);
            return(View(game));
        }
예제 #7
0
        public async Task <IActionResult> Create([Bind("Id,FactoryName,CountryId")] Factory factory)
        {
            if (ModelState.IsValid)
            {
                if (FactoryExists(factory.FactoryName))
                {
                    return(RedirectToAction(nameof(Index)));
                }
                _context.Add(factory);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CountryId"] = new SelectList(_context.Country, "Id", "CountryName", factory.CountryId);
            return(View(factory));
        }
예제 #8
0
        public async Task <IActionResult> Create([Bind("Id,FactoryId,BladeName,Composite")] Blade blade)
        {
            if (ModelState.IsValid)
            {
                if (BladeExists(blade.BladeName))
                {
                    return(RedirectToAction(nameof(Index)));
                }
                _context.Add(blade);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FactoryId"] = new SelectList(_context.Factory, "Id", "FactoryName", blade.FactoryId);
            return(View(blade));
        }
예제 #9
0
        public async Task <IActionResult> Create([Bind("Id,FactoryId,RubberName,Pimples")] Rubber rubber)
        {
            if (ModelState.IsValid)
            {
                if (RubberExists(rubber.FactoryId, rubber.RubberName))
                {
                    return(RedirectToAction(nameof(Index)));
                }
                _context.Add(rubber);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FactoryId"] = new SelectList(_context.Factory, "Id", "FactoryName", rubber.FactoryId);
            return(View(rubber));
        }