public async Task <VoucherBuyResultModel> BuyAsync([FromBody] VoucherBuyModel model) { Voucher voucher; try { voucher = await _purchaseService.BuyAsync(model.CustomerId, model.SpendRuleId); } catch (CustomerNotFoundException) { return(new VoucherBuyResultModel(VoucherErrorCode.CustomerNotFound)); } catch (SpendRuleNotFoundException) { return(new VoucherBuyResultModel(VoucherErrorCode.SpendRuleNotFound)); } catch (InvalidSpendRulePriceException) { return(new VoucherBuyResultModel(VoucherErrorCode.InvalidSpendRulePrice)); } catch (InvalidSpendRuleVerticalException) { return(new VoucherBuyResultModel(VoucherErrorCode.InvalidSpendRuleVertical)); } catch (NoEnoughTokensException) { return(new VoucherBuyResultModel(VoucherErrorCode.NoEnoughTokens)); } catch (InvalidConversionException) { return(new VoucherBuyResultModel(VoucherErrorCode.InvalidConversion)); } catch (CustomerWalletBlockedException) { return(new VoucherBuyResultModel(VoucherErrorCode.CustomerWalletBlocked)); } catch (CustomerWalletDoesNotExistException) { return(new VoucherBuyResultModel(VoucherErrorCode.CustomerWalletDoesNotExist)); } catch (NoVouchersInStockException) { return(new VoucherBuyResultModel(VoucherErrorCode.NoVouchersInStock)); } return(new VoucherBuyResultModel(voucher.Id, voucher.Code)); }