Add extension method for millis
This commit is contained in:
parent
743502055d
commit
c5e99d9d8d
3
.gitignore
vendored
3
.gitignore
vendored
@ -2,4 +2,5 @@
|
||||
.fake
|
||||
src/**/bin
|
||||
src/**/obj
|
||||
src/**/appsettings.*.json
|
||||
src/**/appsettings.*.json
|
||||
src/.vs
|
||||
|
@ -20,8 +20,7 @@ namespace JobsJobsJobs.Server.Data
|
||||
/// <returns>A populated citizen</returns>
|
||||
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"));
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve a citizen by their No Agenda Social user name
|
||||
|
@ -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
|
||||
/// <param name="name">The name of the field to be retrieved as a 64-bit integer</param>
|
||||
/// <returns>The specified field as a 64-bit integer</returns>
|
||||
public static long GetInt64(this NpgsqlDataReader rdr, string name) => rdr.GetInt64(rdr.GetOrdinal(name));
|
||||
|
||||
/// <summary>
|
||||
/// Get milliseconds by its name
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the field to be retrieved as milliseconds</param>
|
||||
/// <returns>The specified field as milliseconds</returns>
|
||||
public static Milliseconds GetMilliseconds(this NpgsqlDataReader rdr, string name) =>
|
||||
new Milliseconds(rdr.GetInt64(name));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user