Use OID instead of email for microsoft identifier. Fix PlayerCount route. Add created date to user table. Create spectator icon.
39 lines
1.2 KiB
C#
39 lines
1.2 KiB
C#
using Dapper;
|
|
using Shogi.Contracts.Api;
|
|
using Shogi.Contracts.Types;
|
|
using System.Data.SqlClient;
|
|
|
|
namespace Shogi.Api.Repositories;
|
|
|
|
public class QueryRepository : IQueryRespository
|
|
{
|
|
private readonly string connectionString;
|
|
|
|
public QueryRepository(IConfiguration configuration)
|
|
{
|
|
connectionString = configuration.GetConnectionString("ShogiDatabase");
|
|
}
|
|
|
|
public async Task<ReadSessionsPlayerCountResponse> ReadSessionPlayerCount(string playerName)
|
|
{
|
|
using var connection = new SqlConnection(connectionString);
|
|
|
|
var results = await connection.QueryMultipleAsync(
|
|
"session.ReadSessionPlayerCount",
|
|
new { PlayerName = playerName },
|
|
commandType: System.Data.CommandType.StoredProcedure);
|
|
|
|
var joinedSessions = await results.ReadAsync<SessionMetadata>();
|
|
var otherSessions = await results.ReadAsync<SessionMetadata>();
|
|
return new ReadSessionsPlayerCountResponse
|
|
{
|
|
PlayerHasJoinedSessions = joinedSessions.ToList(),
|
|
AllOtherSessions = otherSessions.ToList()
|
|
};
|
|
}
|
|
}
|
|
|
|
public interface IQueryRespository
|
|
{
|
|
Task<ReadSessionsPlayerCountResponse> ReadSessionPlayerCount(string playerName);
|
|
} |