private async Task <NewJumpStartOverAllStats> GetStatsCoreAsync(DateTime fromDate, DateTime toDate, int?id) { Expression <Func <Data.Entity.Models.Email, bool> > condition; if (id.HasValue) { condition = item => item.NewJumpStartId == id; } else { condition = item => item.NewJumpStartId != null; } var userCountBeforeStart = await _recipientService.GetUserCountAsync(fromDate.AddDays(-1), item => true); var userStats = await GetUserStatsAsync(fromDate, toDate); var openCountBeforeStart = await _emailRecipientService.GetOpenCountUpToAsync(fromDate.AddDays(-1), condition); var openStats = await GetOpenStatsAsync(fromDate, toDate, condition); var clickCountBeforeStart = await _emailRecipientService.GetClickCountUpToAsync(fromDate.AddDays(-1), condition); var clickStats = await GetClickStatsAsync(fromDate, toDate, condition); var tagStats = await GetTagsStatsAsync(fromDate, toDate); return(new NewJumpStartOverAllStats(userCountBeforeStart, userStats, openCountBeforeStart, openStats, clickCountBeforeStart, clickStats, tagStats)); }
public async Task <OverAllStats> GetStatsAsync(DateTime fromDate, DateTime toDate) { var userCountBeforeStart = await _recipientService.GetUserCountAsync(fromDate.AddDays(-1), item => true); var userStats = await GetUserStatsAsync(fromDate, toDate); var openCountBeforeStart = await _emailRecipientService.GetOpenCountUpToAsync(fromDate.AddDays(-1), item => item.MemoId != null); var openStats = await GetOpenStatsAsync(fromDate, toDate); var clickCountBeforeStart = await _emailRecipientService.GetClickCountUpToAsync(fromDate.AddDays(-1), item => item.MemoId != null); var clickStats = await GetClickStatsAsync(fromDate, toDate); return(new OverAllStats(userCountBeforeStart, userStats, openCountBeforeStart, openStats, clickCountBeforeStart, clickStats)); }