Esempio n. 1
0
        /// <summary>
        /// Ctor with ICosmosSettings
        /// </summary>
        /// <param name="cosmosSettings"></param>
        public CosmosRepository(ICosmosSettings cosmosSettings)
        {
            if (cosmosSettings == null)
            {
                throw new ArgumentNullException($"{nameof(cosmosSettings)} reference not set to an instance of an object");
            }

            if (string.IsNullOrEmpty(cosmosSettings.ConnectionString))
            {
                throw new ArgumentNullException($"{nameof(cosmosSettings.ConnectionString)} is null or empty");
            }

            if (string.IsNullOrEmpty(cosmosSettings.DatabaseName))
            {
                throw new ArgumentNullException($"{nameof(cosmosSettings.DatabaseName)} is null or empty");
            }

            if (string.IsNullOrEmpty(cosmosSettings.ContainerName))
            {
                throw new ArgumentNullException($"{nameof(cosmosSettings.ContainerName)} is null or empty");
            }

            _client    = new CosmosClient(cosmosSettings.ConnectionString);
            _database  = _client.GetDatabase(cosmosSettings.DatabaseName);
            _container = _database.GetContainer(cosmosSettings.ContainerName);
        }
Esempio n. 2
0
        public QuestionSetRepository(DocumentClient client, IOptions <CosmosSettings> cosmosSettings)
        {
            this.cosmosSettings = cosmosSettings?.Value;

            if (this.cosmosSettings == null)
            {
                throw new ArgumentNullException(nameof(cosmosSettings));
            }

            this.collectionName = "QuestionSets";
            this.client         = client;
        }
 public QuestionSetRepository(DocumentClient client, IOptions <CosmosSettings> cosmosSettings)
 {
     this.cosmosSettings = cosmosSettings?.Value;
     this.collectionName = "QuestionSets";
     this.client         = client;
 }
Esempio n. 4
0
 public UserSessionRepository(DocumentClient client, IOptions <CosmosSettings> cosmosSettings)
 {
     this.cosmosSettings = cosmosSettings?.Value;
     this.collectionName = "UserSessions";
     this.client         = client;
 }