Skip to content

Commit

Permalink
Got the text saving working
Browse files Browse the repository at this point in the history
  • Loading branch information
nivereno committed Sep 4, 2021
1 parent a9de427 commit e72a496
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion TournamentTrackerLibrary/DataAccess/TextConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ public class TextConnector : IDataConnection
public PrizeModel CreatePrize(PrizeModel model)
{
List<PrizeModel> prizes = PrizesFile.FullFilePath().LoadFile().ConvertToPrizeModels();
int currentId = 1;
if (prizes.Count > 0)
{
currentId = prizes.OrderByDescending(x => x.Id).First().Id + 1;
}

int currentId = prizes.OrderByDescending(x => x.Id).First().Id + 1;
model.Id = currentId;

prizes.Add(model);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static class TextConnectorProcessor
{
public static string FullFilePath(this string fileName)
{
return $"{ ConfigurationManager.AppSettings["filePath"] }\\{ fileName }";
return @"C:\Saved Data for tracker\" + fileName;
}

public static List<string> LoadFile(this string file)
Expand Down Expand Up @@ -55,6 +55,7 @@ public static void SaveToPrizeFile(this List<PrizeModel> models, string fileName
lines.Add($"{ p.Id },{ p.PlaceNumber },{ p.PlaceName },{ p.PrizeAmount },{ p.PrizePercentage }");
}

Directory.CreateDirectory(@"C:\Saved Data for tracker");
File.WriteAllLines(fileName.FullFilePath(), lines);
}
}
Expand Down

0 comments on commit e72a496

Please sign in to comment.