public void TestGetEntriesByEventId() { EntriesController entryContoller = new EntriesController(); var entriesList = entryContoller.GetEntriesByEventId(7); }
// Add athlete results for specific event async Task AddAthleteResults(string filePath, int eventId, AthleteController athleteController, EntriesController entriesController, MarksController markController) { var entriesInfoList = entriesController.GetEntriesByEventId(eventId); List <ResultsEntry> entryResultsList = new List <ResultsEntry>(); foreach (Entry item in entriesInfoList) { entryResultsList.Add(new ResultsEntry { FlightPlace = item.FlightPlace.ToString(), AthleteId = item.AthleteID.ToString(), // CompetePosition = item.CompetePosition.ToString(), This will has the potential to cause errors in the Field Lynx application EventPlace = string.Empty, // Not concerned about event place for mvp LastName = item.LastName, FirstName = item.FirstName, Affiliation = item.TeamName, Wind = string.Empty // Not concerned about wind for mvp }); // Add the marks to the entry result if (item.Marks.Count() > 0) { StringBuilder marksString = new StringBuilder(); foreach (Mark markItem in item.Marks) { marksString.Append(String.Concat(markItem.mark, ",")); } entryResultsList.Last().Mark = marksString.ToString(); } else { entryResultsList.Last().Mark = String.Empty; } } StringBuilder entryText = new StringBuilder(); foreach (ResultsEntry item in entryResultsList) { // Adds the header to each file using (StreamWriter writer = new StreamWriter(filePath, true)) { entryText.Append(String.Concat( item.FlightPlace.ToString(), ",", item.AthleteId.ToString(), ",", String.Empty, ",", // This is where compete position would be item.EventPlace, ",", item.LastName, ",", item.FirstName, ",", item.Affiliation, ",", item.Mark, item.Wind, ",", Environment.NewLine)); await writer.WriteAsync(entryText.ToString()); entryText.Clear(); writer.Close(); } } }