示例#1
0
        public async Task GetUserReport_onlyAccessesOneUserForAllEntriesAndCompressesByDay()
        {
            var report = await webReportService.GetUserReport(userId, defaultDate);

            report.Count.Should().Be(4);
            report.Where(x => x.UserId == userId).ToList().Count.Should().Be(4);
        }
示例#2
0
        public async Task <ViewResult> Index(string selectedMonth = null)
        {
            var userId = await GetUserId();

            var webReportService    = new WebReportService(dbContext);
            var userAvailableMonths = await webReportService.GetUserAvailableMonths(userId);

            DateTime?selectedDate = null;

            if (selectedMonth == null)
            {
                selectedMonth = userAvailableMonths.FirstOrDefault()?.Value;
            }

            if (!String.IsNullOrEmpty(selectedMonth) && DateTime.TryParse(selectedMonth, out DateTime selectedDate2))
            {
                selectedDate = selectedDate2;
            }

            var projectService = new ProjectService(dbContext);
            var items          = await webReportService.GetUserReport(userId, selectedDate ?? DateTime.UtcNow);

            var model = new UserRecordHoursViewModel()
            {
                Hours         = items.ToImmutableList(),
                TimeEntryType = TimeEntryTypeEnum.BillableProject,
                Projects      = (await projectService.GetAllProjects()).ToImmutableList(),
                Name          = items.Any() ? items.First().Name : string.Empty,
                Date          = DateTime.UtcNow.Date,
                Months        = userAvailableMonths,
                SelectedMonth = selectedMonth,
                TotalYearly   = await webReportService.GetTotalHoursYearly(userId, selectedDate?.Year),
                TotalMonthly  = await webReportService.GetTotalHoursMonthly(userId, selectedDate?.Month)
            };

            return(View(model));
        }