Personmodel handled as dbtabel and as file

This commit is contained in:
2020-03-26 20:49:46 +01:00
parent 27f406b836
commit 1a686aba60
8 changed files with 135 additions and 10 deletions

View File

@ -10,6 +10,26 @@ namespace TrackerLibrary.DataAccess
public class TextConnector : IDataConnection
{
private const string PrizesFile = "PrizeModels.csv";
private const string PeopleFile = "PersonModels.csv";
public PersonModel CreatePerson(PersonModel model)
{
List<PersonModel> people = PeopleFile.FullFilePath().LoadFile().ConvertToPersonModels();
int currentId = 1;
if (people.Count > 0)
{
currentId = people.OrderByDescending(x => x.Id).First().Id + 1;
}
model.Id = currentId;
people.Add(model);
people.SaveToPeopleFile(PeopleFile);
return model;
}
// TODO - Wire up the createPrize for textFiles
public PrizeModel CreatePrize(PrizeModel model)