public async Task <int> UpdateCreationCount()
        {
            var characterCreationCount = 0;

            var connectionString = await connectionStringResolver.ResolveConnectionString("DefaultConnectionString");

            using (var connection = new SqlConnection(connectionString))
            {
                await connection.OpenAsync();

                using (var command = new SqlCommand("Creation.GetCharacterCreationCount", connection))
                {
                    command.CommandType = System.Data.CommandType.StoredProcedure;

                    using (var reader = await command.ExecuteReaderAsync())
                    {
                        while (await reader.ReadAsync())
                        {
                            characterCreationCount = reader.GetInt32(reader.GetOrdinal("CreationCount"));
                        }
                    }
                }
            }

            return(characterCreationCount);
        }
Example #2
0
        protected override ISqlConnection GetConnection(string connectionStringName)
        {
            ISqlConnection connection;

            if (!Factories.TryGetValue(connectionStringName, out connection))
            {
                var connectionString = _connectionStringResolver.ResolveConnectionString(connectionStringName);
                connection = new SqlConnection(() => new SqliteConnection(connectionString));
            }

            return(connection);
        }
Example #3
0
        public async Task Save(Character character, Guid creatorId)
        {
            using (var connection = new SqlConnection(await connectionStringResolver.ResolveConnectionString("DefaultConnectionString")))
            {
                await connection.OpenAsync();

                using (var command = new SqlCommand("Character.AddCharacter", connection))
                {
                    command.CommandType = System.Data.CommandType.StoredProcedure;

                    command.Parameters.AddWithValue("@Id", Guid.NewGuid());
                    command.Parameters.AddWithValue("@CreatorId", creatorId);
                    command.Parameters.AddWithValue("@Blob", JsonConvert.SerializeObject(character));

                    await command.ExecuteNonQueryAsync();
                }
            }
        }
        protected override ISqlConnection GetConnection(string connectionStringName)
        {
            ISqlConnection connection;

            if (Factories.TryGetValue(connectionStringName, out connection))
            {
                return(connection);
            }

            var connectionString = _connectionStringResolver.ResolveConnectionString(connectionStringName);

            connection = new SqlConnection(() =>
            {
                var c = new System.Data.SqlClient.SqlConnection(connectionString);
                c.Open();
                return(c);
            });

            return(connection);
        }