Ejemplo n.º 1
0
        public async Task <ICommandExecutionResult> HandleCommand()
        {
            var jobDate = await CommandUtils.ParseDateFromMessage(CommandContext, uowFactory);

            var jobs = await crmService.GetJobsAsync(CommandContext.ChatId, jobDate);

            var jobsList = new StringBuilder();

            foreach (var job in jobs.OrderBy(j => j.jobID))
            {
                jobsList.AppendLine();
                jobsList.AppendFormat(@"*{0}* ```
{1}```", ToTime(job.duration), job.text);
            }

            var totalDuration = jobs
                                .Select(j => j.duration)
                                .DefaultIfEmpty(0)
                                .Sum();

            jobsList.AppendLine();
            jobsList.AppendFormat("Total: *{0}*", ToTime(totalDuration));

            return(new TextResult($@"Jobs for {jobDate:D}" + jobsList.ToString())
            {
                TextFormat = ParseMode.Markdown
            });
        }
Ejemplo n.º 2
0
        public async Task <ICommandExecutionResult> HandleCommand()
        {
            var jobDate = await CommandUtils.ParseDateFromMessage(CommandContext, uowFactory);

            var jobs = await crmService.GetJobsAsync(CommandContext.ChatId, jobDate);

            var billable =
                jobs.Where(j => j.billable)
                .Select(j => j.duration)
                .DefaultIfEmpty(0)
                .Sum();
            var unbillable =
                jobs.Where(j => !j.billable)
                .Select(j => j.duration)
                .DefaultIfEmpty(0)
                .Sum();
            var total = billable + unbillable;

            return(new TextResult($@"Jobs for {jobDate:D}
Total: *{ToTime(total)}*
Billable: *{ToTime(billable)}*
Non-Billable: *{ToTime(unbillable)}*")
            {
                TextFormat = ParseMode.Markdown
            });
        }