public async Task <AUser_User> GetUserAsync(string userId) { using var log = BeginFunction(nameof(UserAdminService), nameof(GetUserAsync), userId); try { await Assert(SecurityPolicy.IsPrivileged).ConfigureAwait(false); using var ctx = QuiltContextFactory.Create(); var dbAspNetUser = await ctx.AspNetUsers .Include(r => r.AspNetUserRoles) .ThenInclude(r => r.Role) .Include(r => r.AspNetUserLogins) .Where(r => r.Id == userId) .FirstOrDefaultAsync().ConfigureAwait(false); if (dbAspNetUser == null) { log.Result(null); return(null); } var squareCustomerReference = CreateSquareCustomerReference.FromUserId(userId); var squareCustomerId = await SquareMicroService.LookupSquareCustomerIdAsync(squareCustomerReference).ConfigureAwait(false); var mSquareCustomerSummaryList = squareCustomerId != null ? await SquareMicroService.GetSquareCustomerSummariesAsync(squareCustomerId.Value, null).ConfigureAwait(false) : null; var mSquarePaymentSummaryList = squareCustomerId != null ? await SquareMicroService.GetSquarePaymentSummariesAsync(squareCustomerId, null, null).ConfigureAwait(false) : null; var ordererReference = CreateOrdererReference.FromUserId(userId); var ordererId = await OrderMicroService.LookupOrdererAsync(ordererReference).ConfigureAwait(false); var mOrderSummaryList = ordererId != null ? await OrderMicroService.GetOrderSummariesAsync(null, null, MOrder_OrderStatus.MetaAll, ordererId, null).ConfigureAwait(false) : null; var result = Create.AUser_User( dbAspNetUser, mOrderSummaryList, mSquareCustomerSummaryList?.Summaries.FirstOrDefault(), mSquarePaymentSummaryList); log.Result(result); return(result); } catch (Exception ex) { log.Exception(ex); throw; } }
public async Task <ASquare_PaymentSummaryList> GetPaymentSummariesAsync(long?squareCustomerId, DateTime?paymentDateUtc, int?recordCount) { using var log = BeginFunction(nameof(SquareAdminService), nameof(GetPaymentSummariesAsync), squareCustomerId, recordCount); try { await Assert(SecurityPolicy.IsPrivileged).ConfigureAwait(false); var mPaymentSummaryList = await SquareMicroService.GetSquarePaymentSummariesAsync(squareCustomerId, paymentDateUtc, recordCount); var result = new ASquare_PaymentSummaryList() { MSummaries = mPaymentSummaryList.Summaries }; log.Result(result); return(result); } catch (Exception ex) { log.Exception(ex); throw; } }