diff --git a/.gitignore b/.gitignore index a3b24b2..73822bd 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ .fake src/**/bin src/**/obj -src/**/appsettings.*.json \ No newline at end of file +src/**/appsettings.*.json +src/.vs diff --git a/src/JobsJobsJobs/Server/Data/CitizenExtensions.cs b/src/JobsJobsJobs/Server/Data/CitizenExtensions.cs index 01a5eca..b2e4cd2 100644 --- a/src/JobsJobsJobs/Server/Data/CitizenExtensions.cs +++ b/src/JobsJobsJobs/Server/Data/CitizenExtensions.cs @@ -20,8 +20,7 @@ namespace JobsJobsJobs.Server.Data /// A populated citizen private static Citizen ToCitizen(NpgsqlDataReader rdr) => new Citizen(CitizenId.Parse(rdr.GetString("id")), rdr.GetString("na_user"), rdr.GetString("display_name"), - rdr.GetString("profile_url"), new Milliseconds(rdr.GetInt64("joined_on")), - new Milliseconds(rdr.GetInt64("last_seen_on"))); + rdr.GetString("profile_url"), rdr.GetMilliseconds("joined_on"), rdr.GetMilliseconds("last_seen_on")); /// /// Retrieve a citizen by their No Agenda Social user name diff --git a/src/JobsJobsJobs/Server/Data/NpgsqlDataReaderExtensions.cs b/src/JobsJobsJobs/Server/Data/NpgsqlDataReaderExtensions.cs index 6663fcc..f5bbda4 100644 --- a/src/JobsJobsJobs/Server/Data/NpgsqlDataReaderExtensions.cs +++ b/src/JobsJobsJobs/Server/Data/NpgsqlDataReaderExtensions.cs @@ -1,4 +1,5 @@ -using Npgsql; +using JobsJobsJobs.Shared; +using Npgsql; using System; using System.Collections.Generic; using System.Linq; @@ -24,5 +25,13 @@ namespace JobsJobsJobs.Server.Data /// The name of the field to be retrieved as a 64-bit integer /// The specified field as a 64-bit integer public static long GetInt64(this NpgsqlDataReader rdr, string name) => rdr.GetInt64(rdr.GetOrdinal(name)); + + /// + /// Get milliseconds by its name + /// + /// The name of the field to be retrieved as milliseconds + /// The specified field as milliseconds + public static Milliseconds GetMilliseconds(this NpgsqlDataReader rdr, string name) => + new Milliseconds(rdr.GetInt64(name)); } }