// TODO: maybe move this in to golf year stuff? This is nastyyyy private async Task <IEnumerable <string> > SaveRoster(string roster, IEnumerable <team> teams, year yearToSave) { if (string.IsNullOrEmpty(roster)) { return(new LinkedList <string>()); } using (RosterReader rosterReader = new RosterReader(new MemoryStream(Encoding.UTF8.GetBytes(roster)))) { var rosters = rosterReader.GetRoster(teams); // This fetches all players from the previous two years, as they may be in the league again this year. RosterInitializer rosterInitializer = new RosterInitializer(rosters, await this.Db.players.Where(x => x.playeryeardatas.Any(y => y.year.value > yearToSave.value - 4)).ToListAsync(), yearToSave); rosterInitializer.PersistRosters(this.Db); return(rosterInitializer.NewPlayers); } }
public void RosterImportWorks() { var rosterTestDataFile = Directory.GetCurrentDirectory() + @"\TestData\rosterTestData.txt"; using (var reader = new RosterReader(new FileStream(rosterTestDataFile, FileMode.Open))) { var results = reader.GetRoster(new List <team> { new team { teamName = "Pinseekers" }, new team { teamName = "Eagles" }, new team { teamName = "Missing Links" } }); Assert.AreEqual(3, results.Count()); Assert.AreEqual("Missing Links", results.First().Team.teamName); Assert.AreEqual(3, results.First().GetPlayers().Count()); } }