Exemplo n.º 1
0
        public Task <Guid> PostCreateViewModelAsync(ProviderApplicationsReportCreateEditModel model, VacancyUser user)
        {
            DateTime fromDate;
            DateTime toDate = _timeProvider.Today;

            switch (model.DateRange)
            {
            case DateRangeType.Last7Days:
                fromDate = _timeProvider.Today.AddDays(-7);
                break;

            case DateRangeType.Last14Days:
                fromDate = _timeProvider.Today.AddDays(-14);
                break;

            case DateRangeType.Last30Days:
                fromDate = _timeProvider.Today.AddDays(-30);
                break;

            case DateRangeType.Custom:
                fromDate = model.FromDate.AsDateTimeUk().Value.ToUniversalTime();
                toDate   = model.ToDate.AsDateTimeUk().Value.ToUniversalTime();
                break;

            default:
                throw new NotImplementedException($"Cannot handle this date range type:{model.DateRange.ToString()}");
            }

            var reportName = $"{fromDate.ToUkTime().AsGdsDate()} to {toDate.ToUkTime().AsGdsDate()}";

            DateTime toDateInclusive = toDate.AddDays(1).AddTicks(-1);

            return(_client.CreateProviderApplicationsReportAsync(model.Ukprn, fromDate, toDateInclusive, user, reportName));
        }