コード例 #1
0
        protected override async Task <SlackMessageResponse> RespondTo(ReportInterpretedMessage message)
        {
            var userService = new UserService(dbContext);
            var user        = await userService.FindOrCreateSlackUser(message.UserId, message.UserName);

            var userReportSvc = new UserReportService(dbContext, user.UserId);

            return(await DecideWhichReportToGenerate(message, userReportSvc));
        }
コード例 #2
0
 public UserReportServiceTest(InMemoryDatabaseWithProjectsAndUsers inMemoryDatabase)
 {
     entryService      = new TimeEntryService(userId, inMemoryDatabase.Database);
     userReportService = new UserReportService(inMemoryDatabase.Database, userId);
 }
コード例 #3
0
        private static async Task <SlackMessageResponse> GenerateDateReport(ReportInterpretedMessage message, UserReportService userReportSvc)
        {
            TimeEntryReport report = await userReportSvc.GetHoursSummaryForDay(message.Date);

            return(new SlackMessageResponse(report.ToDayMessage(), true));
        }
コード例 #4
0
        private static async Task <SlackMessageResponse> GenerateMonthReport(ReportInterpretedMessage message, UserReportService userReportSvc)
        {
            TimeEntryReport report = await userReportSvc.GetHoursSummaryMonth(message.Date.Month, Convert.ToInt32(message.Year));

            return(new SlackMessageResponse(report.ToMonthlyMessage(), true));
        }
コード例 #5
0
        private static async Task <SlackMessageResponse> GenerateDefaultReport(UserReportService userReportSvc)
        {
            TimeEntryReport report = await userReportSvc.GetHoursSummaryDefaultWeekMonthAndYtd();

            return(new SlackMessageResponse(report.ToWeekMonthAndYTDMessage(), true));
        }
コード例 #6
0
        private static async Task <SlackMessageResponse> GenerateLast10EntryReport(UserReportService userReportSvc)
        {
            var stringReport = await userReportSvc.GetLastTenEntries();

            return(new SlackMessageResponse(stringReport, true));
        }
コード例 #7
0
        private static async Task <SlackMessageResponse> DecideWhichReportToGenerate(ReportInterpretedMessage message, UserReportService userReportSvc)
        {
            switch (message.ToGenerate)
            {
            case ReportType.ForSpecificDate:
                return(await GenerateDateReport(message, userReportSvc));

            case ReportType.ForMonth:
                return(await GenerateMonthReport(message, userReportSvc));

            case ReportType.ForYear:
                return(await GenerateYearReport(message, userReportSvc));

            case ReportType.ForMostRecent:
                return(await GenerateLast10EntryReport(userReportSvc));

            default:
                return(await GenerateDefaultReport(userReportSvc));
            }
        }