private async Task <Result <Product, ProductsErrorCodes> > CurrencyMustExist(Product value, string userName, string correlationId, Product existing = null) { var currencyResult = await _currenciesService.GetByIdAsync(value.TradingCurrency); if (currencyResult.IsFailed) { return(new Result <Product, ProductsErrorCodes>(ProductsErrorCodes.CurrencyDoesNotExist)); } return(new Result <Product, ProductsErrorCodes>(value)); }
public async Task <GetCurrencyByIdResponse> GetByIdAsync([FromRoute][Required] string id) { var result = await _currenciesService.GetByIdAsync(id); var response = new GetCurrencyByIdResponse(); if (result.IsSuccess) { response.Currency = _convertService.Convert <Currency, CurrencyContract>(result.Value); } if (result.IsFailed) { response.ErrorCode = _convertService.Convert <CurrenciesErrorCodes, CurrenciesErrorCodesContract>(result.Error.Value); } return(response); }