public async Task <IActionResult> Generate() { Team team = new Team("Team Name"); _context.Add(team); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <IActionResult> Create([Bind("LeagueID,LeagueName")] League league) { if (ModelState.IsValid) { _context.Add(league); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(league)); }
// TODO: 3a) Make sure that this is binding to the 'Position' property public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,Number,TeamId")] Player player) { if (ModelState.IsValid) { _context.Add(player); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(player)); }
public async Task <IActionResult> Create([Bind("YearsExperience,ElementarySchool,GuardianName,ID,LastName,FirstName,MiddleName,BirthDay")] Player player) { if (ModelState.IsValid) { _context.Add(player); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(player)); }
public async Task <IActionResult> Create([Bind("Id,Name")] Team team) { if (ModelState.IsValid) { _context.Add(team); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(team)); }
public async Task <IActionResult> Create([Bind("SubmitBackGroundCheck,Position,YearsExperience,ID,LastName,FirstName,MiddleName")] Volunteer volunteer) { if (ModelState.IsValid) { _context.Add(volunteer); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(volunteer)); }
public async Task <IActionResult> Create([Bind("SubmitBackGroundCheck,Position,YearsExperience,ID,LastName,FirstName,MiddleName,Birthday," + "PhoneNumber,Street,City,State,Zipcode")] Volunteer volunteer) { if (ModelState.IsValid) { _context.Add(volunteer); await _context.SaveChangesAsync(); return(View("Confirm")); } return(View(volunteer)); }
public async Task <IActionResult> Create([Bind("YearsExperience,ElementarySchool,GuardianName,ID,LastName,FirstName,MiddleName,BirthDay," + "PhoneNumber,Street,City,Zipcode")] Player player) { if (ModelState.IsValid) { _context.Add(player); await _context.SaveChangesAsync(); return(View("Confirm")); } return(View(player)); }
public async Task Save(List <League> leaguesToSave, List <Team> teamsToSave, string leagueCode) { foreach (var league in leaguesToSave) { await LeagueContext.Leagues.AddAsync(league); //Check if Team exists var newTeams = RemoveExistingTeams(teamsToSave); await LeagueContext.Teams.AddRangeAsync(newTeams); //LeagueTeam foreach (var team in teamsToSave) { var leagueTeams = new List <LeagueTeam>(); var leagueTeam = new LeagueTeam { League = league, Team = team }; leagueTeams.Add(leagueTeam); await LeagueContext.LeagueTeam.AddAsync(leagueTeam); await LeagueContext.SaveChangesAsync(); team.LeagueId = league.LeagueId; } } var importedLeague = new ImportedLeague { LeagueCodeId = leagueCode }; await LeagueContext.ImportedLeagues.AddAsync(importedLeague); await LeagueContext.SaveChangesAsync(); }
public async Task <int> Save() { return(await _dbContext.SaveChangesAsync()); }