Personmodel handled as dbtabel and as file
This commit is contained in:
@ -44,6 +44,23 @@ namespace TrackerLibrary.DataAccess.TextHelpers
|
||||
return output;
|
||||
}
|
||||
|
||||
public static List<PersonModel> ConvertToPersonModels(this List<string> lines)
|
||||
{
|
||||
List<PersonModel> output = new List<PersonModel>();
|
||||
foreach(string line in lines)
|
||||
{
|
||||
string[] cols = line.Split(',');
|
||||
PersonModel p = new PersonModel();
|
||||
p.Id = int.Parse(cols[0]);
|
||||
p.FirstName = cols[1];
|
||||
p.LastName = cols[2];
|
||||
p.EmailAddress = cols[3];
|
||||
p.CellPhoneNumber = cols[4];
|
||||
output.Add(p);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
public static void SaveToPrizeFile(this List<PrizeModel> models, string fileName)
|
||||
{
|
||||
List<string> lines = new List<string>();
|
||||
@ -54,5 +71,17 @@ namespace TrackerLibrary.DataAccess.TextHelpers
|
||||
}
|
||||
File.WriteAllLines(fileName.FullFilePath(), lines);
|
||||
}
|
||||
|
||||
public static void SaveToPeopleFile(this List<PersonModel> models, string fileName)
|
||||
{
|
||||
List<string> lines = new List<string>();
|
||||
foreach(PersonModel p in models)
|
||||
{
|
||||
lines.Add($"{p.Id},{p.FirstName},{p.LastName},{p.EmailAddress},{p.CellPhoneNumber}");
|
||||
}
|
||||
|
||||
File.WriteAllLines(fileName.FullFilePath(), lines);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user