// GET: Teams/Edit/5 public ActionResult Edit(long?id) { if (id == null) { return(HttpNotFound()); } Team team = _list.Read((long)id); team.Players = PlayersConverter.ParseStringToList(team.PlayersConcat); if (team == null) { return(HttpNotFound()); } return(ViewForm("Edit", "Edit", team)); }
public ActionResult FixBensTeam(int id) { Team team = _list.Read((long)id); team.Players = PlayersConverter.ParseStringToList(team.PlayersConcat); string pr = "8471469"; string ma = "8470594"; //getting player's from db List <string> pIds = team.Players; pIds.Remove(pr); pIds.Add(ma); team.Players = pIds; team.PlayersConcat = PlayersConverter.ConvertListToString(team.Players); _list.Update(team); return(RedirectToAction("Index")); }
// GET: Team public ActionResult Index(string nextPageToken) { var tList = _list.List(_pageSize, nextPageToken); foreach (var team in tList.Teams) { team.Players = PlayersConverter.ParseStringToList(team.PlayersConcat); } var sortedteams = tList.Teams.ToList().OrderBy(t => t.Points).Reverse(); tList.Teams = sortedteams; return(View(new ViewModels.Teams.Index() { TeamList = tList })); }
// GET: Teams/Edit/5 public ActionResult UpdateTeams(long?id) { var tList = new List <Team>(); if (id == null) { tList = _list.List(_pageSize, null).Teams.ToList(); } else { tList.Add(_list.Read((long)id)); } foreach (var team in tList) { team.Players = PlayersConverter.ParseStringToList(team.PlayersConcat); int assists = 0; int goals = 0; int wins = 0; int so = 0; int points = 0; foreach (var player in team.Players) { var pfdb = _pool.List(0, null).Players.Where(p => p.playerCode == player).First(); assists += pfdb.assists; goals += pfdb.goals; wins += pfdb.wins; so += pfdb.shutouts; points = (goals + assists + wins + so); } team.Assists = assists; team.Goals = goals; team.Wins = wins; team.Shutouts = so; team.Points = points; _list.Update(team); } return(RedirectToAction("Index")); }
// GET: Teams/Details/5 public ActionResult Details(long?id) { if (id == null) { return(HttpNotFound()); } Team team = _list.Read((long)id); team.Players = PlayersConverter.ParseStringToList(team.PlayersConcat); //getting player's from db List <string> pIds = team.Players; var tPlayers = _pool.List(0, null).Players.Where(p => pIds.Contains(p.playerCode)).ToList(); tPlayers.OrderBy(x => x.team); //Processing Points ViewBag.Players = tPlayers; if (team == null) { return(HttpNotFound()); } return(View(team)); }