public async Task <IndexResult> CreateIndex([FromBody] string indexName)
        {
            var createIndex = new IndexResult();

            if (string.IsNullOrEmpty(indexName))
            {
                createIndex.Messages = new List <AlertViewModel> {
                    new AlertViewModel("danger", "no indexName defined", "Please provide the index name"),
                };
                return(createIndex);
            }

            try
            {
                await _searchProviderIndex.CreateIndex().ConfigureAwait(false);

                createIndex.Messages = new List <AlertViewModel>  {
                    new AlertViewModel("success", "Index created", "The Azure Search index was created successfully!"),
                };
                var indexStatus = await _searchProviderIndex.GetIndexStatus().ConfigureAwait(false);

                createIndex.Status.IndexExists   = indexStatus.Exists;
                createIndex.Status.DocumentCount = indexStatus.DocumentCount;
                return(createIndex);
            }
            catch (Exception ex)
            {
                createIndex.Messages = new List <AlertViewModel> {
                    new AlertViewModel("danger", "Error creating index", ex.Message),
                };
                return(createIndex);
            }
        }
        public async Task <ActionResult> OnPostCreateIndexAsync()
        {
            try
            {
                await _searchProviderIndex.CreateIndex().ConfigureAwait(false);

                Messages = new[] {
                    new AlertViewModel("success", "Index created", "The Azure Search index was created successfully!"),
                };
                var indexStatus = await _searchProviderIndex.GetIndexStatus().ConfigureAwait(false);

                IndexExists   = indexStatus.Exists;
                DocumentCount = indexStatus.DocumentCount;
                return(Page());
            }
            catch (Exception ex)
            {
                Messages = new[] {
                    new AlertViewModel("danger", "Error creating index", ex.Message),
                };
                return(Page());
            }
        }