public async Task <AReturn_ReturnRequest> GetReturnRequestAsync(long returnRequestId) { using var log = BeginFunction(nameof(ReturnAdminService), nameof(GetReturnRequestAsync), returnRequestId); try { await Assert(SecurityPolicy.IsPrivileged).ConfigureAwait(false); var mReturnRequest = await FulfillmentMicroService.GetReturnRequestAsync(returnRequestId); var mTransactions = await FulfillmentMicroService.GetReturnRequestTransactionSummariesAsync(returnRequestId, null, null); var mEvents = await FulfillmentMicroService.GetReturnRequestEventLogSummariesAsync(returnRequestId, null, null); var mFulfillables = new List <MFulfillment_Fulfillable>(); foreach (var mReturnRequestItem in mReturnRequest.ReturnRequestItems) { // Retrieve the associated fulfillable if we haven't already. // var fulfillableId = mReturnRequestItem.FulfillableId; if (!mFulfillables.Any(r => r.FulfillableId == fulfillableId)) { var mFulfillable = await FulfillmentMicroService.GetFulfillableAsync(fulfillableId).ConfigureAwait(false); mFulfillables.Add(mFulfillable); } } var allowEdit = await SecurityPolicy.AllowEditFulfillment(); var returnRequest = Create.AReturn_ReturnRequest(mReturnRequest, mTransactions, mEvents, mFulfillables, allowEdit); var result = returnRequest; log.Result(result); return(result); } catch (Exception ex) { log.Exception(ex); throw; } }