public async Task DeleteAsync(string id) { try { await _pnLStopLossEngineService.DeleteAsync(id); } catch (EntityNotFoundException) { throw new ValidationApiException(HttpStatusCode.NotFound, "PnL stop loss engine does not exist."); } catch (InvalidOperationException exception) { throw new ValidationApiException(HttpStatusCode.BadRequest, exception.Message); } }
public async Task DeleteAsync(string id) { await GetSettingsByIdAsync(id); await _pnLStopLossSettingsRepository.DeleteAsync(id); _cache.Remove(id); var pnLStopLossEngines = (await _pnLStopLossEngineService.GetAllAsync()).Where(x => x.PnLStopLossSettingsId == id).ToList(); foreach (var pnLStopLossEngine in pnLStopLossEngines) { await _pnLStopLossEngineService.DeleteAsync(pnLStopLossEngine.Id); } _log.InfoWithDetails($"PnL stop loss settings deleted with {pnLStopLossEngines.Count} engines.", id); }