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)); }
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)); }
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 })); }
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)); }
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)); }
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)); }
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)); }
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)); }