Example #1
0
        public async Task <ActionResult> Delete(AdminEditViewModel model)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageIndexes))
            {
                return(Unauthorized());
            }

            if (!_luceneIndexManager.Exists(model.IndexName))
            {
                return(NotFound());
            }

            try
            {
                _luceneIndexManager.DeleteIndex(model.IndexName);

                _notifier.Success(H["Index <em>{0}</em> deleted successfully", model.IndexName]);
            }
            catch (Exception e)
            {
                _notifier.Error(H["An error occurred while deleting the index"]);
                Logger.LogError("An error occurred while deleting the index " + model.IndexName, e);
            }

            return(RedirectToAction("Index"));
        }