private ActionResult PrepareResponseAfterGetConfiguration(IGetConfigurationResponse getConfigurationResponse) { // ReSharper disable once ConvertSwitchStatementToSwitchExpression switch (getConfigurationResponse.Result) { case GetConfigurationResultEnum.Exception: return(StatusCode(500)); case GetConfigurationResultEnum.Success: return(StatusCode(200, new ConfigurationApiModel { Key = getConfigurationResponse.ConfigurationObject.Key, Value = getConfigurationResponse.ConfigurationObject.Value })); case GetConfigurationResultEnum.NotFound: return(StatusCode(404)); case GetConfigurationResultEnum.InvalidKey: return(StatusCode(400)); default: throw new ArgumentOutOfRangeException(); } }
public async Task <ActionResult> GetConfig(string key) { try { IGetConfigurationRequest getConfigurationRequest = new GetConfigurationRequest(key); IGetConfigurationResponse getConfigurationResponse = await _configurationProvider.GetConfigurationResponse(getConfigurationRequest); return(PrepareResponseAfterGetConfiguration(getConfigurationResponse)); } catch (Exception ex) { _logger.Log(ex); return(StatusCode(500)); } }