dlmelendez/identitydocumentdb

User defined collection names

Closed this issue · 1 comments

Since DocumentDB on Azure now charges by the collection, it makes more sense to let the user of this library control where the UserStore and RoleStore are backed in the database.

I have modified the Constants file so that it reads the UsersCollection and RolesCollection names from the WebConfig file instead of being hard-coded by the library.

For instance:

public static class AppSettingsKeys
        {
            public const string DatabaseNameKey = "IdDocDb_Database";
            public const string DatabaseUriKey = "IdDocDb_Uri";
            public const string DatabaseAuthKey = "IdDocDb_AuthKey";
            public const string RolesCollectionKey = "IdDocDb_RolesCollectionKey";
            public const string UsersCollectionKey = "IdDocDb_UsersCollectionKey";
        }

public static class DocumentCollectionIds
        {
            private static string _rolesCollection;
            private static string _usersCollection;

            public static string RolesCollection
            {
                get
                {
                    if (string.IsNullOrEmpty(_rolesCollection))
                    {
                        _rolesCollection = ConfigurationManager.AppSettings[AppSettingsKeys.RolesCollectionKey];
                    }
                    return _rolesCollection;
                }
            }

            public static string UsersCollection
            {
                get
                {
                    if (string.IsNullOrEmpty(_usersCollection))
                    {
                        _usersCollection = ConfigurationManager.AppSettings[AppSettingsKeys.UsersCollectionKey];
                    }
                    return _usersCollection;
                }
            }
        }

Let me know if you'd like me to create a pull request to submit this work.

Cheers,
Jon

@dlmelendez can you please have a look at my pull request and see if it fits your requirements.
If it's merged in master, could you please make a new nuget package so we could use this in production?

Thanks