public TeamSheet Read(string filePath) { teamSheet = new TeamSheet(); package = new ExcelPackage(new FileInfo(filePath)); sheet1 = package.Workbook.Worksheets[1]; int totalManagers = 0; for (int i = 2; i < sheet1.Dimension.End.Column; i++) { var manager = sheet1.Cells[1, i].Value; if (manager != null) { AddTeam(manager.ToString().Trim(), 1, i); totalManagers++; } var manager2 = sheet1.Cells[36, i].Value; if (manager2 != null) { AddTeam(manager2.ToString().Trim(), 36, i); totalManagers++; } } if (totalManagers == 0) { return(null); } return(teamSheet); }
public void Update(TeamSheet teamSheet) { foreach (var team in teamSheet.Teams) { var managerId = db.Managers.Where(x => x.Alias == team.Manager).Select(x => x.ManagerId).FirstOrDefault(); if (managerId != 0) { db.ManagerGoalKeepers.RemoveRange(db.ManagerGoalKeepers.Where(x => x.ManagerId == managerId)); db.ManagerPlayers.RemoveRange(db.ManagerPlayers.Where(x => x.ManagerId == managerId)); MapTeams(team, managerId); MapPlayers(team, managerId); } } db.SaveChanges(); }