Esempio n. 1
0
        public IActionResult GetTab(
            [FromRoute, Required] string device,
            [FromRoute, Required] string tab,
            [FromQuery] PaginationRequestDto paginationDto,
            [FromQuery] SortRequestDto sortDto,
            [FromQuery] AdvancedFilterRequestDto filterRequestDto)
        {
            try
            {
                var deviceId   = new DeviceId(device);
                var filter     = AdvancedFilterRequestDto.ParseFilterRequest(filterRequestDto);
                var pagination = PaginationRequestDto.MapPaginationRequest(paginationDto);
                var sort       = SortRequestDto.MapSortRequest(sortDto);

                var tabEntries = _DataModel.GetTab(deviceId, tab, pagination, sort, filter);

                return(Json(tabEntries));
            }
            catch (UnknownDeviceIdException e)
            {
                Logger.LogError("Exception while execution:", e);
                return(FormattedNotFound($"Device id not found."));
            }
            catch (UnknownKeyException e)
            {
                Logger.LogError("Exception while execution:", e);
                return(FormattedNotFound($"Key not found."));
            }
            catch (Exception e)
            {
                Logger.LogError("Exception while execution:", e);
                return(FormattedInternalServerError($"{nameof(e)} {e.Message}"));
            }
        }
Esempio n. 2
0
        public IActionResult GetJobs(
            [FromRoute, Required] string device,
            [FromQuery, Optional] PaginationRequestDto paginationDto,
            [FromQuery, Optional] SortRequestDto sortDto,
            [FromQuery, Optional] AdvancedFilterRequestDto filterRequestDto)
        {
            try
            {
                var deviceId   = new DeviceId(device);
                var filter     = AdvancedFilterRequestDto.ParseFilterRequest(filterRequestDto);
                var pagination = PaginationRequestDto.MapPaginationRequest(paginationDto);
                var sort       = SortRequestDto.MapSortRequest(sortDto);

                var jobEntries = _jobModel.GetJobs(deviceId, pagination, sort, filter);

                return(Json(jobEntries));
            }
            catch (Exception e)
            {
                return(ResolveException(e));
            }
        }