Esempio n. 1
0
        public IHttpActionResult GetTimeEntriesByDay(
            [FromUri] string UserScope,
            [FromUri] int[] UserIds,
            [FromUri] string JobScope,
            [FromUri] int[] JobIds,
            [FromUri] DateTime Min,
            [FromUri] DateTime Max)
        {
            var currentUser = CurrentUser();

            telemetryClient.TrackTrace($"Generating TimeEntriesByDay report for {Min:G} through {Max:G}");

            // Ensure that user is authorized.
            if (!currentUser.CanViewReports)
            {
                return(StatusCode(HttpStatusCode.Forbidden));
            }

            var bytes = new TimeCardsByDayAsExcel().Build(currentUser, Min, Max, UserScope, UserIds, JobScope, JobIds);

            return(new FileActionResult(
                       bytes,
                       "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
                       $"Report - Time Cards by Day {Min.ToString("yyyy_MM_dd")} thru {Max.ToString("yyyy_MM_dd")}.xlsx",
                       Request));
        }
Esempio n. 2
0
        public IActionResult GetTimeEntriesByDay(
            [FromQuery] string UserScope,
            [FromQuery] int[] UserIds,
            [FromQuery] string JobScope,
            [FromQuery] int[] JobIds,
            [FromQuery] DateTime Min,
            [FromQuery] DateTime Max)
        {
            var currentUser = CurrentUser();

            _telemetryClient.TrackTrace($"Generating TimeEntriesByDay report for {Min:G} through {Max:G}");

            // Ensure that user is authorized.
            if (!currentUser.CanViewReports)
            {
                return(Forbid());
            }

            var bytes = new TimeCardsByDayAsExcel().Build(_context, currentUser, Min, Max, UserScope, UserIds, JobScope, JobIds);

            return(File(
                       bytes,
                       "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
                       fileDownloadName: $"Report - Time Cards by Day {Min.ToString("yyyy_MM_dd")} thru {Max.ToString("yyyy_MM_dd")}.xlsx"));
        }