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

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

            try
            {
                await _searchProviderIndex.DeleteIndex(indexName).ConfigureAwait(false);

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

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

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

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