public ActionResult Create(int GroupId1, int GroupId2, int Week, int Team1Score, int Team2Score) { Schedule schedule = new Schedule(); if (GroupId1 != 0) { schedule.GroupId1 = GroupId1; } if (GroupId2 != 0) { schedule.GroupId2 = GroupId2; } if (Week != 0) { schedule.Week = Week; } if (Team1Score != 0) { schedule.Team1Score = Team1Score; } if (Team2Score != 0) { schedule.Team2Score = Team2Score; } _db.Schedules.Add(schedule); _db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Create(League league) { league.CurrentWeek = 1; league.CurrentSeason = 1; _db.Leagues.Add(league); _db.SaveChanges(); var userId = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value; var currentUser = await _userManager.FindByIdAsync(userId); Group groupRow = new Group { LeagueId = league.LeagueId, User = currentUser, TeamName = "Commish", LeagueSeason = league.CurrentSeason, OwnerRole = "Commissioner" }; _db.Groups.Add(groupRow); _db.SaveChanges(); Standing standing = new Standing { LeagueId = league.LeagueId, GroupId = groupRow.GroupId, TeamName = groupRow.TeamName, Wins = 0, Ties = 0, Losses = 0, PtsFor = 0, PtsAgst = 0, LeagueName = league.LeagueName }; _db.Standings.Add(standing); _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult ConfirmRemove(int id) { Group groupToBeInactive = _db.Groups.FirstOrDefault(x => x.GroupId == id); groupToBeInactive.Active = 0; _db.Entry(groupToBeInactive).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult AddPlayer(int id, int groupId) //commish add players to rosterc { System.Console.WriteLine(_db.Rosters.Where(x => x.GroupId == groupId).Count()); if (_db.Rosters.Where(x => x.GroupId == groupId).Count() <= 12) // Sets roster size { System.Console.WriteLine(id); System.Console.WriteLine(groupId); var p = Player.GetPlayerFromApi(id); Roster roster = new Roster(); roster.GroupId = groupId; roster.PlayerId = id; roster.Position = "bench"; roster.FootballPosition = p.Result.Position; roster.LastName = p.Result.LastName; roster.FirstName = p.Result.FirstName; _db.Rosters.Add(roster); _db.SaveChanges(); } else { //send error back "over roster size limit" } return(RedirectToAction("Index", new { id = groupId })); //might have to change which view }
public ActionResult Create(Tracker Tracker) { _db.Trackers.Add(Tracker); _db.SaveChanges(); return(RedirectToAction("Index")); }