private async Task <Roster> CreateRoster( Guid matchdayId, string userId, string[] playerIds) { var players = new List <RosterPlayer>(); double budget = GlobalConstants.Budget; foreach (var id in playerIds) { var player = await this.playerRepository .GetByIdAsync(new Guid(id)); budget -= player.Price; var pr = new RosterPlayer { Player = player }; players.Add(pr); } return(new Roster { Formation = Formation.Formation442, UserId = userId, Budget = budget, Players = players, MatchdayId = matchdayId }); }
private async Task AddRosterPlayers(Roster roster, string[] playersIn) { foreach (var id in playersIn) { var player = await this.playerRepository .GetByIdAsync(new Guid(id)); roster.Budget -= player.Price; var rp = new RosterPlayer { Player = player }; roster.Players.Add(rp); } }