AspnetApiAndDocumentDB.Data.MovieRepository.GetOrCreateCollection C# (CSharp) Method

GetOrCreateCollection() public static method

public static GetOrCreateCollection ( string databaseLink, string collectionId ) : DocumentCollection
databaseLink string
collectionId string
return DocumentCollection
        public static DocumentCollection GetOrCreateCollection(string databaseLink, string collectionId)
        {
            var col = Client.CreateDocumentCollectionQuery(databaseLink)
                              .Where(c => c.Id == collectionId)
                              .AsEnumerable()
                              .FirstOrDefault();

            if (col == null)
            {
                col = client.CreateDocumentCollectionAsync(databaseLink,
                    new DocumentCollection { Id = collectionId },
                    new RequestOptions { OfferType = "S1" }).Result;
            }

            return col;
        }