예제 #1
0
        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;
            }
        }
예제 #2
0
        public async Task <ASquare_CustomerSummaryList> GetCustomerSummariesAsync(long?squareCustomerId, int?recordCount)
        {
            using var log = BeginFunction(nameof(SquareAdminService), nameof(GetCustomerSummariesAsync), squareCustomerId, recordCount);
            try
            {
                await Assert(SecurityPolicy.IsPrivileged).ConfigureAwait(false);

                var mCustomerSummaryList = await SquareMicroService.GetSquareCustomerSummariesAsync(squareCustomerId, recordCount);

                var result = new ASquare_CustomerSummaryList()
                {
                    MSummaries = mCustomerSummaryList.Summaries
                };

                log.Result(result);

                return(result);
            }
            catch (Exception ex)
            {
                log.Exception(ex);
                throw;
            }
        }