示例#1
0
        public async Task <Maybe <MasterGameChangeRequest> > GetMasterGameChangeRequest(Guid requestID)
        {
            var sql = "select * from tbl_mastergame_changerequest where RequestID = @requestID";

            using (var connection = new MySqlConnection(_connectionString))
            {
                MasterGameChangeRequestEntity entity = await connection.QuerySingleOrDefaultAsync <MasterGameChangeRequestEntity>(sql, new { requestID });

                if (entity == null)
                {
                    return(Maybe <MasterGameChangeRequest> .None);
                }

                var masterGame = await GetMasterGame(entity.MasterGameID);

                if (masterGame.HasNoValue)
                {
                    throw new Exception($"Something has gone horribly wrong with master game change requests. ID: {requestID}");
                }

                var user = await _userStore.FindByIdAsync(entity.UserID.ToString(), CancellationToken.None);

                return(entity.ToDomain(user, masterGame.Value));
            }
        }
示例#2
0
    public async Task CreateMasterGameChangeRequest(MasterGameChangeRequest domainRequest)
    {
        var entity = new MasterGameChangeRequestEntity(domainRequest);

        await using var connection = new MySqlConnection(_connectionString);
        await connection.ExecuteAsync(
            "insert into tbl_mastergame_changerequest(RequestID,UserID,RequestTimestamp,RequestNote,MasterGameID,OpenCriticID,GGToken,Answered,ResponseTimestamp,ResponseNote,Hidden) VALUES " +
            "(@RequestID,@UserID,@RequestTimestamp,@RequestNote,@MasterGameID,@OpenCriticID,@GGToken,@Answered,@ResponseTimestamp,@ResponseNote,@Hidden);",
            entity);
    }