public async Task <IHttpActionResult> Configure() { var jsonReply = new JObject(); IIndexer indexer = null; try { var postData = await ReadPostDataJson(); string indexerString = (string)postData["indexer"]; indexer = indexerService.GetIndexer((string)postData["indexer"]); jsonReply["name"] = indexer.DisplayName; var configurationResult = await indexer.ApplyConfiguration(postData["config"]); if (configurationResult == IndexerConfigurationStatus.RequiresTesting) { await indexerService.TestIndexer((string)postData["indexer"]); } else if (configurationResult == IndexerConfigurationStatus.Failed) { throw new Exception("Configuration Failed"); } jsonReply["result"] = "success"; } catch (Exception ex) { jsonReply["result"] = "error"; jsonReply["error"] = ex.Message; var baseIndexer = indexer as BaseIndexer; if (null != baseIndexer) { baseIndexer.ResetBaseConfig(); } if (ex is ExceptionWithConfigData) { jsonReply["config"] = ((ExceptionWithConfigData)ex).ConfigData.ToJson(null, false); } else { logger.Error(ex, "Exception in Configure"); } } return(Json(jsonReply)); }