/// <summary> /// Gets the details of a merchant /// </summary> /// <param name="merchantId">The merchant id</param> /// <returns>merchant object</returns> public async Task <Merchant> GetMerchantByIdAsync(MerchantId merchantId) { await using PaymentControllerDbContext context = DbContextProvider.Create(); Model.Merchant merchant = await context.Merchant.Where(x => x.MerchantId.Equals(merchantId.UUID)).SingleOrDefaultAsync(); return(merchant.ToDto()); }
/// <summary> /// Adds a new merchant account /// </summary> /// <param name="merchant">Details of new merchant</param> /// <returns>bool</returns> public async Task <bool> CreateMerchantAccountAsync(Merchant merchant) { await using PaymentControllerDbContext context = DbContextProvider.Create(); try { Model.Merchant dbMerchant = merchant.ToDb(); context.Merchant.Add(dbMerchant); int result = await context.SaveChangesAsync().ConfigureAwait(false); return(result.Equals(1)); } catch (Exception ex) { Logger.LogWarning(ex, "An exception has occured in {name}", nameof(CreateMerchantAccountAsync)); throw; } }