public async Task <IMerchant> CreateAsync(IMerchant merchant) { merchant.TrimProperties(); IReadOnlyList <IMerchant> apiKeyMerchants = await _merchantRepository.FindApiKeyAsync(merchant.ApiKey); if (apiKeyMerchants.Any()) { throw new DuplicateMerchantApiKeyException(merchant.ApiKey); } IMerchant emailMerchant = await _merchantRepository.FindEmailAsync(merchant.Email); if (emailMerchant != null) { throw new DuplicateMerchantEmailException(merchant.Email); } IMerchant createdMerchant = await _merchantRepository.InsertAsync(merchant); _log.Info("Merchant created", merchant); return(createdMerchant); }