public static async Task <List <EarnBurnHistory> > GetEarnBurnHistory(Guid userId) { CustomerServiceEntities dbContext = new CustomerServiceEntities(); var query = from il in dbContext.QueryEarnBurnLineItems() where il.GlobalId == userId select new EarnBurnHistory { }; return(await query.ToListAsync()); }
public static async Task <List <EarnBurnLineItem> > GetEarnBurnLineItems(Guid userId) { CommerceEntities commerceDbContext = new CommerceEntities(); // Cards Dictionary <int, string> cardBrands = await(from cb in commerceDbContext.CardBrands select cb).ToDictionaryAsync(x => x.Id, x => x.Name); // TransactionReviewStatus Dictionary <int, string> trReviewStatus = await(from trs in commerceDbContext.TransactionReviewStatus select trs).ToDictionaryAsync(x => x.Id, x => x.Name); // Credit Status Dictionary <int, string> creditStatus = await(from trs in commerceDbContext.CreditStatus select trs).ToDictionaryAsync(x => x.Id, x => x.Name); CustomerServiceEntities customerServiceDbContext = new CustomerServiceEntities(); customerServiceDbContext.Database.CommandTimeout = 0; var query = from li in customerServiceDbContext.QueryEarnBurnLineItems() where li.GlobalId == userId orderby li.TransactionDate descending select new EarnBurnLineItem { TransactionId = li.TransactionId, UserId = li.GlobalId, TransactionDate = li.TransactionDate, EarnCredit = Math.Round((double)li.EarnCredit / 100, 2), BurnDebit = Math.Round((double)li.BurnDebit / 100, 2), HasRedeemedDealRecord = li.HasRedeemedDealRecord, TransactionTypeId = li.TransactionType, DealSummary = li.DealSummary, DealPercent = li.DealPercent, MerchantName = li.MerchantName, TransactionAmount = Math.Round((double)li.TransactionAmount / 100, 2), Reversed = li.Reversed, TransactionStatusId = li.TransactionStatusId, Last4Digits = li.LastFourDigits, CardBrandId = li.CardBrand, PermaPending = li.PermaPending, ReviewStatusId = li.ReviewStatusId, RedeemDealId = li.RedeemedDealId }; List <EarnBurnLineItem> result = await query.ToListAsync(); foreach (var row in result) { row.TransactionType = row.TransactionTypeId == CommerceDal.BurnTransactionType ? "Burn" : "Earn"; row.TransactionStatus = row.TransactionStatusId.HasValue && creditStatus.ContainsKey(row.TransactionStatusId.Value) ? creditStatus[row.TransactionStatusId.Value] : string.Empty; row.CardBrand = row.CardBrandId.HasValue && cardBrands.ContainsKey(row.CardBrandId.Value) ? cardBrands[row.CardBrandId.Value] : string.Empty; row.ReviewStatus = row.ReviewStatusId.HasValue && trReviewStatus.ContainsKey(row.ReviewStatusId.Value) ? trReviewStatus[row.ReviewStatusId.Value] : string.Empty; } return(result); }