private IEnumerable<SecondRoundPrediction> GetSecondRoundPrediction(int participantId, int predictionType) { HetEKSpelEntities db = new HetEKSpelEntities(connectionString); var predictions = db.Predictions.Where(p => p.Participant_Id == participantId && p.PredictionType_Id == predictionType).ToList(); var teams = db.Teams.ToList(); var predictionList = new List<SecondRoundPrediction>(); foreach (var prediction in predictions) { var predictionLine = new SecondRoundPrediction { TeamId = (int)prediction.Team_Id, TeamName = teams.SingleOrDefault(t => t.Id == prediction.Team_Id).Team1, Short = teams.SingleOrDefault(t => t.Id == prediction.Team_Id).Short, PredictionType = prediction.PredictionType_Id, Points = prediction.Points.ToString() }; predictionList.Add(predictionLine); } return predictionList; }
private List<SecondRoundPrediction> GetSecoundroutePrediction(List<Prediction> participantPredictions, int predictionType) { var secondRoundPredictions = participantPredictions.Where(p => p.PredictionType_Id == predictionType).ToList(); var secondRoundPredictionList = new List<SecondRoundPrediction>(); var teams = db.Teams.ToList(); foreach (var secondRoundPrediction in secondRoundPredictions) { var teamName = teams.Single(t => t.Id == secondRoundPrediction.Team_Id).Team1; var prediction = new SecondRoundPrediction { TeamName = teamName, Points = secondRoundPrediction.Points.ToString() }; secondRoundPredictionList.Add(prediction); } return secondRoundPredictionList; }