Create team form is ready (nearly)
This commit is contained in:
@ -11,6 +11,7 @@ namespace TrackerLibrary.DataAccess
|
||||
{
|
||||
private const string PrizesFile = "PrizeModels.csv";
|
||||
private const string PeopleFile = "PersonModels.csv";
|
||||
private const string TeamFile = "TeamModels.csv";
|
||||
|
||||
public PersonModel CreatePerson(PersonModel model)
|
||||
{
|
||||
@ -59,6 +60,35 @@ namespace TrackerLibrary.DataAccess
|
||||
return model;
|
||||
}
|
||||
|
||||
public TeamModel CreateTeam(TeamModel model)
|
||||
{
|
||||
// Load the text file
|
||||
// Convert the text to a List>PrizeModel>
|
||||
List<TeamModel> teams = TeamFile.FullFilePath().LoadFile().ConvertToTeamModels(PeopleFile);
|
||||
|
||||
// Find the max Id
|
||||
|
||||
int currentId = 1;
|
||||
|
||||
if (teams.Count > 0)
|
||||
{
|
||||
currentId = teams.OrderByDescending(x => x.Id).First().Id + 1;
|
||||
}
|
||||
|
||||
model.Id = currentId;
|
||||
|
||||
// Add the new record with the new ID (max +1)
|
||||
teams.Add(model);
|
||||
|
||||
|
||||
|
||||
// Convert the prizes to a List<string>
|
||||
// Save the list<String> to the text file
|
||||
teams.SaveToTeamFile(TeamFile);
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
public List<PersonModel> GetPerson_All()
|
||||
{
|
||||
return PeopleFile.FullFilePath().LoadFile().ConvertToPersonModels();
|
||||
|
||||
Reference in New Issue
Block a user