public async Task GetTotalHoursMonthly() { await this.PopulateTimeEntries(defaultDate.AddYears(-1)); var totalHours = await webReportService.GetTotalHoursMonthly(this.userId, defaultDate.Month); totalHours.TotalBillable.Should().BeGreaterOrEqualTo(0); totalHours.TotalSick.Should().BeGreaterOrEqualTo(0); totalHours.TotalNonBillable.Should().BeGreaterOrEqualTo(0); totalHours.TotalVacation.Should().BeGreaterOrEqualTo(0); await PopulateTimeEntries(defaultDate.AddMonths(-1)); if (this.defaultDate.Day > 15) { await this.PopulateTimeEntries(defaultDate); } else { await this.PopulateTimeEntries(defaultDate.AddDays(10)); } var totalHours2 = await webReportService.GetTotalHoursMonthly(this.userId, defaultDate.Month); totalHours2.TotalBillable.Should().Be(36); totalHours2.TotalSick.Should().Be(4); totalHours2.TotalVacation.Should().Be(8); totalHours2.TotalNonBillable.Should().Be(14); }
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)); }