public IActionResult Delete(string id, [FromServices] IServiceProvider serviceProvider, [FromServices] ProcessQuery processQuery) { var service = serviceQuery.Get(id); if (service == null) { return(new StatusCodeResult(StatusCodes.Status404NotFound)); } switch (service.Type) { case (int)ServiceTypeEnum.Classifier: var classifierHandler = serviceProvider.GetService <ClassifierServiceHandler>(); classifierHandler.Delete(service); serviceQuery.DeleteSettings <ClassifierSettingsElastic>(service.Id); break; case (int)ServiceTypeEnum.Prc: var prcHandler = serviceProvider.GetService <PrcServiceHandler>(); prcHandler.Delete(service); serviceQuery.DeleteSettings <PrcSettingsElastic>(service.Id); break; case (int)ServiceTypeEnum.Search: var searchHandler = serviceProvider.GetService <SearchServiceHandler>(); searchHandler.Delete(service); serviceQuery.DeleteSettings <SearchSettingsWrapperElastic>(service.Id); break; } serviceQuery.Delete(service); GlobalStore.ServiceAliases.Remove(service.Alias); if (service.ProcessIdList != null) { processQuery.Delete(service.ProcessIdList); } return(new StatusCodeResult(StatusCodes.Status200OK)); }