Beispiel #1
0
        public JsonResult GetStatistic(string date, int page, int pageSize)
        {
            if (!this.permissionService.Authorize(StandardPermissionProvider.StatisticConsumption))
            {
                return(AccessDeniedJson());
            }

            DateTime selectedDate;

            if (!DateTime.TryParse(date, out selectedDate))
            {
                return(null);
            }

            var timesheet = timesheetService.GetTimesheetByDate(page, pageSize, selectedDate);

            var result =
                Enumerable.Where(timesheet.Select(Mapper.Map <Timesheet, TimesheetModel>), model => model != null)
                .ToList();

            return(Json(
                       new
            {
                data = result,
                total = result.Count
            },
                       JsonRequestBehavior.AllowGet));
        }